I showed prompt to user to enable gps settings,but how can I check user really enabled the gps location on his phone?
private static void showGPSDisabledAlertToUser() {
// TODO Auto-generated method stub
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ChatSDK.getSDKInstance().activity);
alertDialogBuilder
.setMessage(
"GPS is disabled in your device. Would you like to enable it?")
.setCancelable(false)
.setPositiveButton("Goto Settings Page To Enable GPS",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent callGPSSettingIntent = new Intent(
android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
ChatSDK.getSDKInstance().activity.startActivity(callGPSSettingIntent);
}
});
// alertDialogBuilder.setNegativeButton("Cancel",
// new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// dialog.cancel();
// }
// });
AlertDialog alert = alertDialogBuilder.create();
alert.show();
}
}
if (!((LocationManager) context.getSystemService(Context.LOCATION_SERVICE))
.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
//prompt user to enable gps
}else{
//gps is enabled
}
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