【发布时间】:2014-04-26 21:23:26
【问题描述】:
我向用户显示了启用 gps 设置的提示,但我如何检查用户是否真的在他的手机上启用了 gps 位置?
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();
}
}
【问题讨论】:
-
保留一个布尔值并最初设置为 false 并在发送意图时将其更改为 true。并检查 onResume 是否为真检查那里的 gps 连接并将布尔值更改为假。
-
@user3152953 查看我的答案,如果您想了解其他信息,请给我详细信息,
标签: android