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!
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.
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”.
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(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With