简体   繁体   English

java.lang.SecurityException:用户 11029 和当前进程都没有 android.permission.SET_TIME_ZONE

[英]java.lang.SecurityException: Neither user 11029 nor current process has android.permission.SET_TIME_ZONE

I am working on an old project which sets time zone programatically, i am migrating this project to Api 28, it works without error on Kitkat device but in Api 28, SET_TIME_ZONE permission can't be granted, as i know it became system level permission and can't be available for apps.我正在开发一个以编程方式设置时区的旧项目,我正在将此项目迁移到 Api 28,它在 Kitkat 设备上运行没有错误,但在 Api 28 中,SET_TIME_ZONE 级别权限无法授予,因为我知道它变成了系统级别权限并且不能用于应用程序。

I have added this permissions我已添加此权限

<uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.SET_TIME_ZONE"
    tools:ignore="ProtectedPermissions" />

and Activity onCreate method looks like this和 Activity onCreate 方法看起来像这样

int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, 2654);
} 
AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
am.setTimeZone("Asia/Tbilisi");

and getting error on Api 28 or higher并在 Api 28 或更高版本上出现错误

java.lang.SecurityException: Neither user 11029 nor current process has android.permission.SET_TIME_ZONE.

I want to keep this functionality, whats your advice what should i use instead of AlarmManager.setTimeZone() method to change system time?我想保留此功能,您有什么建议我应该使用什么来代替 AlarmManager.setTimeZone() 方法来更改系统时间?

Prompt for timezone selection.if you need the user to select a specific zone,give a message with the instruction before opening setting activity to prompt the user.After selecting,you can then check if the system timezone is as expected and take whatever action.提示选择时区。如果您需要用户 select 一个特定的区域,在打开设置活动之前给用户一条指令以提示用户。选择后,您可以检查系统时区是否符合预期并采取任何措施。

startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.SecurityException:需要 BLUETOOTH 权限:用户 10065 和当前进程都没有 android.permission.BLUETOOTH - java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10065 nor current process has android.permission.BLUETOOTH Android棒棒糖java.lang.SecurityException:用户和当前进程都没有android.permission.BLUETOOTH_PRIVILEGED - Android lollipop java.lang.SecurityException: Neither user nor current process has android.permission.BLUETOOTH_PRIVILEGED 正在获取java.lang.SecurityException:ConnectivityService:用户10062或当前进程都没有android.permission.ACCESS_NETWORK_STATE。” - Geting java.lang.SecurityException: ConnectivityService: Neither user 10062 nor current process has android.permission.ACCESS_NETWORK_STATE." Java.lang.SecurityException:Android中的安全权限? - Java.lang.SecurityException:SECURE PERMISSION in android? 用户10031和当前进程都没有android.permission.INSTALL_PACKAGES - Neither user 10031 nor current process has android.permission.INSTALL_PACKAGES java.lang.SecurityException:权限拒绝:用户的获取/设置设置要求以用户-2身份运行,但正在从用户0调用 - java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0 Android:java.lang.SecurityException - Android: java.lang.SecurityException java.lang.SecurityException:权限被拒绝 - java.lang.SecurityException: Permission denied java.lang.SecurityException:权限拒绝错误 - java.lang.SecurityException: Permission Denial ERROR java.lang.SecurityException:权限被拒绝(缺少INTERNET权限?),即使在android清单中添加了此权限 - java.lang.SecurityException: Permission denied (missing INTERNET permission?) even with adding this permission in android manifest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM