KISHORE_ZE
KISHORE_ZE

Reputation: 1466

Turn on location services automatically in Android 3.1 and above

I know that from android 3.1 and above you can't turn on location services manually. But in Google maps it simply shows an dialog which prompts me to switch it on. This directly switches it on (In android 5.1 - Lollipop). So how does google do it? Is it some Google location services API I can use or should I direct the user to the location services settings screen? Thanks.

Upvotes: 1

Views: 161

Answers (1)

e4c5
e4c5

Reputation: 53734

The are making use of theSettingsApi It allows you to check if the location services are available on the device and there is a complete example provided by google on github that shows how to use this API. The sample code will prompt the user to enable location if it's switched off. The dialog that pops up when you fire the intent is similar to what you see in Google Maps.

Upvotes: 1

Related Questions