我有一个使用位置功能的安卓应用程序。但是我注意到如果用户在“设置”>“位置访问”中禁用了“访问我的位置”,那么什么都不起作用了。如何检查它是否已启用?
如果被禁用,如何从我的应用程序打开这些设置?
谢谢
已解决:
String locationProviders = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if (locationProviders == null || locationProviders.equals("")) {
...
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
LocationManager.GPS_PROVIDER
替换为LocationManager.NETWORK_PROVIDER
)。 - BrtleSettings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
,但我会尝试一下。另外,我提供了一个提示来打开位置源设置。 - Brtle