I am suffering from the problem of getting value 0.0 as latitude and longitude in Android Marshmallow (API 23) i.e. 6.0.
I have searched a lot regar
First, remove these:
Those are defined by the platform, not you.
Also, you are not reacting when the user actually grants permission to you. Request the permissions in your activity, and do not create an instance of GPSTracker
until you have permission. That may be immediately, if checkSelfPermission()
says that you have permission. Otherwise, that will be when the activity is called with onRequestPermissionResult()
.
The location work itself is also buggy, in that you seem to think that you will get a location immediately, which will not be the case much of the time.