检查位置的服务能或不在安卓设备

0

的问题

抱歉问这个但我不是一开发的应用程序。 我想问问,如果一个定制的地理位置安卓应用程序编码在这样一种方式,当用户启动的应用程序和检测设备的位置服务是关闭的,它将显示出作为一个提示或程序将不进行进一步到位的服务是通过用户手动?

我们使用的是移动设备管理(mdm)管理移动设备,但mdm没有能力强制实施的位置的服务设置。

定制的地理位置安卓应用程序需要的位置的服务能够正常工作。

android geolocation gps location
2021-11-17 13:42:19
1

最好的答案

0

你可以检查是否GPS启用或不显示的消息,如果它未启用

        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

        if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {

            //here do what you want when the GPS service is enabled

            Toast.makeText(MainActivity.this, "is enable", Toast.LENGTH_SHORT).show();

        } else {

            MaterialAlertDialogBuilder locationDialog = new MaterialAlertDialogBuilder(MainActivity.this);
            locationDialog.setTitle("Attention");
            locationDialog.setMessage("Location settings must be enabled from the settings to use the application");
            locationDialog.setCancelable(false);
            locationDialog.setPositiveButton("Open settings", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                    startActivity(intent);
                }
            });
            locationDialog.create().show();
        }

    }
}
2021-11-17 16:06:51

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................