Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open GPS settings an android device? [closed]

Tags:

I am making GPS android app (with air for android) and what I want is if GPS is off I want to open GPS settings on device or switch GPS on but I don't know how. I want to do it in AS3 or open android settings in Java. Thanks for help!

like image 777
Tinko Avatar asked Apr 13 '14 08:04

Tinko


People also ask

How do I force open location on Android?

Open your phone's Settings app. Under "Personal," tap Location access. At the top of the screen, turn Access to my location on or off.

Can I find my Android phone if location is turned off?

If you ever get lucky and your missing cell phone is still on, you can use “Find My Device” to locate it in real-time. Otherwise, when your phone is offline, turned off, or out of battery, you will be able to see the last location where your phone can be found, using “Find My Device”.


1 Answers

You can simply start an activity with this action:

startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); 

I use it inside a dialog:

public static void displayPromptForEnablingGPS(final Activity activity)     {          final AlertDialog.Builder builder =  new AlertDialog.Builder(activity);         final String action = Settings.ACTION_LOCATION_SOURCE_SETTINGS;         final String message = "Do you want open GPS setting?";          builder.setMessage(message)             .setPositiveButton("OK",                 new DialogInterface.OnClickListener() {                     public void onClick(DialogInterface d, int id) {                         activity.startActivity(new Intent(action));                         d.dismiss();                     }             })             .setNegativeButton("Cancel",                 new DialogInterface.OnClickListener() {                     public void onClick(DialogInterface d, int id) {                         d.cancel();                     }             });         builder.create().show();     } 
like image 169
GVillani82 Avatar answered Sep 18 '22 16:09

GVillani82