GPS是否开启
LocationManager locationManager = (LocationManager)getContext().
getSystemService(Context.LOCATION_SERVICE);
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
进入GPS设置页面
Intent intent = new Intent();
intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try
{
getContext().startActivity(intent);
} catch(ActivityNotFoundException ex)
{
// The Android SDK doc says that the location settings activity
// may not be found. In that case show the general settings.
// General settings activity
intent.setAction(Settings.ACTION_SETTINGS);
try {
getContext().startActivity(intent);
} catch (Exception e) {
}
}
本文介绍了一种方法来检查Android设备上的GPS是否启用,并提供代码示例来引导用户进入GPS设置页面。如果无法直接打开GPS设置,则会转至通用设置。
1365

被折叠的 条评论
为什么被折叠?



