How to redirect to the GPS settings window in Android or ios using the handset to turn GPS on or off

I want to implement such functionality as Native android in phone records, when a user wants to turn on gps at this time by pressing a button, he will be redirected to the Android or IOS settings section so that the user can click on the GPS button. Since we cannot programmatically connect or disconnect GPS on the device directly, we can redirect the user to the setting in order to redirect the user to the setting in the Android and IOS phone

I want to implement below functionality in a telephone bundle, can someone help me.

/** * Function to check if best network provider * @return boolean * */ public boolean canGetLocation() { return this.canGetLocation; } /** * Function to show settings alert dialog * */ public void showSettingsAlert(){ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext); // Setting Dialog Title alertDialog.setTitle("GPS is settings"); // Setting Dialog Message alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?"); // Setting Icon to Dialog //alertDialog.setIcon(R.drawable.delete); // On pressing Settings button alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int which) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); mContext.startActivity(intent); } }); // on pressing cancel button alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); } 
+7
source share
1 answer
 startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); 

try a friend of this intention, he will transfer you to the location settings ...

+7
source

All Articles