Reputation: 31
I have just started working on a android project and is using the Google Map API.
I am able to fetch the map on my app but when i try to enable the current location with map.setMyLocationEnabled(true);
, the app says unfortunately app has stopped working.
When I removed the line map.setMyLocationEnabled(true);
then it worked fine. Can anyone please help me to get the current location button enabled.
Upvotes: 2
Views: 4119
Reputation: 8200
If you are using android 6.0 or above, you should:
ACCESS_COARSE_LOCATION
and ACCESS_FINE_LOCATION
in your AndroidManifest
file. Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. This approach streamlines the app install process, since the user does not need to grant permissions when they install or update the app. It also gives the user more control over the app's functionality;
If you want an easy-to-use library for permission checking, I suggest Permission Dispatcher.
Upvotes: 1
Reputation: 9458
According to this, you need to have requested permission for either ACCESS_COARSE_LOCATION
or ACCESS_FINE_LOCATION
.
My guess is you haven't and your app is throwing a SecurityException
.
Upvotes: 0