【发布时间】:2017-02-02 08:47:53
【问题描述】:
使用提示打开 GPS 后刷新地图/活动。 我已经这样做了,但它不会刷新活动。 这是我的代码:
public void showSettingsAlert(){
AlertDialog.Builder alertDialog = new AlertDialog.Builder(HomeActivity.this);
// 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.mipmap.ic_launcher);
// 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);
HomeActivity.this.startActivity(intent);
loadData();
}
});
// on pressing cancel button
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
// Showing Alert Message
alertDialog.show();
}
如何刷新活动?
checkGPS();
私人无效 checkGPS() { if (!SmartLocation.with(this).location().state().locationServicesEnabled() || !SmartLocation.with(this).location().state().isAnyProviderAvailable()) { maketoast("定位服务未开启!!"); 显示设置警报(); } }
【问题讨论】:
-
在活动的 onResume 方法中刷新地图。
-
添加您的地图类代码!
-
无限循环获取Activity
-
发布您的代码。
-
我添加了checkGPS()的代码;
标签: android google-maps gps