Android 如何检查设备在颤振状态下是否启用GPS?
如何检查设备上是否启用了GPS功能,以便更新地图小部件。我已经完成了位置权限处理程序功能部分。将包添加到您的项目中,然后您可以使用以下工具检查位置是否已启用:Android 如何检查设备在颤振状态下是否启用GPS?,android,google-maps,flutter,Android,Google Maps,Flutter,如何检查设备上是否启用了GPS功能,以便更新地图小部件。我已经完成了位置权限处理程序功能部分。将包添加到您的项目中,然后您可以使用以下工具检查位置是否已启用: final geoloator\u geoloator=geoloator(); ... ... bool enabled=wait_geological.isLocationServiceEnabled(); 我在重复这个问题时遇到问题 根据这一点,最好的方法是 final LocationManager manager = (Loc
final geoloator\u geoloator=geoloator();
...
...
bool enabled=wait_geological.isLocationServiceEnabled();
我在重复这个问题时遇到问题
根据这一点,最好的方法是
final LocationManager manager = (LocationManager) getSystemService( Context.LOCATION_SERVICE );
if ( !manager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) {
buildAlertMessageNoGps();
}
private void buildAlertMessageNoGps() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Your GPS seems to be disabled, do you want to enable it?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
dialog.cancel();
}
});
final AlertDialog alert = builder.create();
alert.show();
}
谢谢你这正是我需要的