Reputation: 1584
I had a simple question about how can we enable or launch the Google Location Setting -> Access Location in our application. And i am talking about the new Setting that google has updated.
EDIT :
Intent to open google Setting i found was only this:
Intent settings = new Intent();
settings.setPackage("com.google.android.gms");
settings.addCategory(Intent.CATEGORY_LAUNCHER);
starrtActivity(settings);
but i wan to open 'Access Location'
,
can we directly enable location access or use an Intent to open location access.
I also checked out the developers site, but dint found one in below
ACTION_LOCATION_SOURCE_SETTINGS
If its possible then do let me know, as it might enable our application to get the latest accurate location available.
Upvotes: 3
Views: 2868
Reputation: 115
String action = "com.google.android.gms.location.settings.GOOGLE_LOCATION_SETTINGS"; Intent settings = new Intent(action); startActivity(settings);
I can access google settings using this. But if any way to check this setting is enabled or not?
Upvotes: 1
Reputation: 191
The answer above launches the android location settings, however if you follow google's advice they suggestion you use Google Play Services locations api. Based on the image provide, it's the Google Play Services Location settings we're looking for:
String action = "com.google.android.gms.location.settings.GOOGLE_LOCATION_SETTINGS";
Intent settings = new Intent(action);
startActivity(settings);
Research:
Unfortunately this action does not appear to be published anywhere. However, it's pretty straight forward to extract an AndroidManifest.xml file from an APK using apktool. I did this and found the activity declaration including intent filters for the activity we're looking for: com.google.android.location.settings.GoogleLocationSettingsActivity.
Magic. :)
Upvotes: 1
Reputation: 221
You can open the settings using Intent
, try this:
Intent viewIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(viewIntent);
Upvotes: 10