Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java setTimeZone()在android 9中不工作(API 28)_Java_Android_Permissions - Fatal编程技术网

Java setTimeZone()在android 9中不工作(API 28)

Java setTimeZone()在android 9中不工作(API 28),java,android,permissions,Java,Android,Permissions,我想为我的系统应用程序设置时区()。它在设备安卓4.2(API 17)中运行良好。但当我迁移到设备Android 9(API 28)时,我得到了错误的信息: java.lang.SecurityException: Neither user 11029 nor current process has android.permission.SET_TIME_ZONE 我已经添加了这些权限,但什么也没有发生 <uses-permission android:name="android.per

我想为我的系统应用程序设置时区()。它在设备安卓4.2(API 17)中运行良好。但当我迁移到设备Android 9(API 28)时,我得到了错误的信息:

java.lang.SecurityException: Neither user 11029 nor current process has android.permission.SET_TIME_ZONE
我已经添加了这些权限,但什么也没有发生

<uses-permission android:name="android.permission.SET_TIME_ZONE" tools:ignore="ProtectedPermissions" android:protectionLevel="signature|system"></uses-permission>
<uses-permission android:name="android.permission.SET_TIME" tools:ignore="ProtectedPermissions"/>

我想保留此功能,您有什么建议我应该使用什么来代替AlarmManager.setTimeZone()方法来更改系统时间?

“我已经添加了此权限,但什么也没有发生”android:protectionLevel不包含在
元素中。您的系统应用程序需要由固件签名密钥签名,或者需要安装在特权分区上。其次是我的应用程序没有安装正确的分区。是否有其他可能导致此问题的原因?您可能希望与固件的维护人员联系,并向他们征求与此特定环境相关的建议。是否有其他方法可以将系统的时区更改为特定城市?“我已添加此权限,但什么也没有发生”--
android:protectionLevel
不在
元素中。您的系统应用程序需要由固件签名密钥签名,或者需要安装在特权分区上。其次是我的应用程序没有安装正确的分区。是否有其他可能导致此问题的原因?您可能希望联系固件的维护人员,并向他们征求与此特定环境相关的建议。是否有其他方法可以将系统的时区更改为特定城市?
public void setTimeZone(String timeZone) {
  ((AlarmManager) mContext.getApplicationContext().getSystemService(Context.ALARM_SERVICE))
      .setTimeZone(timeZone);
}