我正在开发一个包含谷歌地图的项目.当活动加载时,我想检查GPS是否启用.所以我使用以下代码重定向到包含设置的页面.
if(!manager.isProviderEnabled( LocationManager.GPS_PROVIDER ))
{
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
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);
startActivity(callGPSSettingIntent);
}
});
alertDialogBuilder.setNegativeButton("Cancel",int id){
dialog.cancel();
}
});
AlertDialog alert = alertDialogBuilder.create();
alert.show();
}
但问题是,如果我启用GPS并返回应用程序,我希望页面再次加载,以便加载地图.如何确保我的活动再次运行?