在设置上写入值时出现 IllegalArgument 异常
IllegalArgument Exception while writing value on settings
我正在尝试使用 putInt 写入值。我要写入的设置是 -
"android.settings.CAMERA_COVER_STATUS"
"android.settings.MIC_SWITCH_STATUS"
我不确定上述设置是否正确。但是当我尝试在它们上面写值时,出现以下错误 -
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): java.lang.IllegalArgumentException: You cannot keep your settings in the secure settings.
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.content.ContentProviderProxy.call(ContentProviderNative.java:651)
2021-09-25 22:48:04.371 INFO logcat: LYNC PAL(6468): findClass java/net/Inet6Address loader 0x23c6
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.provider.Settings$NameValueCache.putStringForUser(Settings.java:1851)
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.provider.Settings$System.putStringForUser(Settings.java:2275)
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.provider.Settings$System.putIntForUser(Settings.java:2380)
2021-09-25 22:48:04.372 INFO logcat: LYNC PAL(6468): findClass java/net/Inet4Address loader 0x23c6
2021-09-25 22:48:04.372 WARNING logcat: System.err(4223): at android.provider.Settings$System.putInt(Settings.java:2374)
2021-09-25 22:48:04.372 WARNING logcat: System.err(4223): at
2021-09-25 22:48:04.372 WARNING logcat: System.err(4223): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
2021-09-25 22:48:04.372 WARNING logcat: System.err(4223): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
2021-09-25 22:48:04.372 WARNING logcat: System.err(4223): at java.lang.Thread.run(Thread.java:764)
我们将不胜感激任何类型的建议和帮助。
已修复。不得不使用系统设置前缀来解决这个问题。在设置键前添加前缀“settings://system/”。现在密钥变成如下 -
"settings://system/android.settings.CAMERA_COVER_STATUS"
"settings://system/android.settings.MIC_SWITCH_STATUS"
还使用以下代码测试了这些值 -
cameraStatus = Settings.System.getInt(this.getContentResolver(),"android.settings.CAMERA_COVER_STATUS",1);
micStatus =Settings.System.getInt(this.getContentResolver(),"android.settings.MIC_SWITCH_STATUS", 1);
他们似乎工作正常。
注意:自己添加了答案,这样如果有人遇到类似的问题,它可能会有所帮助。
我正在尝试使用 putInt 写入值。我要写入的设置是 -
"android.settings.CAMERA_COVER_STATUS"
"android.settings.MIC_SWITCH_STATUS"
我不确定上述设置是否正确。但是当我尝试在它们上面写值时,出现以下错误 -
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): java.lang.IllegalArgumentException: You cannot keep your settings in the secure settings.
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.content.ContentProviderProxy.call(ContentProviderNative.java:651)
2021-09-25 22:48:04.371 INFO logcat: LYNC PAL(6468): findClass java/net/Inet6Address loader 0x23c6
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.provider.Settings$NameValueCache.putStringForUser(Settings.java:1851)
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.provider.Settings$System.putStringForUser(Settings.java:2275)
2021-09-25 22:48:04.371 WARNING logcat: System.err(4223): at android.provider.Settings$System.putIntForUser(Settings.java:2380)
2021-09-25 22:48:04.372 INFO logcat: LYNC PAL(6468): findClass java/net/Inet4Address loader 0x23c6
2021-09-25 22:48:04.372 WARNING logcat: System.err(4223): at android.provider.Settings$System.putInt(Settings.java:2374)
2021-09-25 22:48:04.372 WARNING logcat: System.err(4223): at
2021-09-25 22:48:04.372 WARNING logcat: System.err(4223): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
2021-09-25 22:48:04.372 WARNING logcat: System.err(4223): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
2021-09-25 22:48:04.372 WARNING logcat: System.err(4223): at java.lang.Thread.run(Thread.java:764)
我们将不胜感激任何类型的建议和帮助。
已修复。不得不使用系统设置前缀来解决这个问题。在设置键前添加前缀“settings://system/”。现在密钥变成如下 -
"settings://system/android.settings.CAMERA_COVER_STATUS"
"settings://system/android.settings.MIC_SWITCH_STATUS"
还使用以下代码测试了这些值 -
cameraStatus = Settings.System.getInt(this.getContentResolver(),"android.settings.CAMERA_COVER_STATUS",1);
micStatus =Settings.System.getInt(this.getContentResolver(),"android.settings.MIC_SWITCH_STATUS", 1);
他们似乎工作正常。
注意:自己添加了答案,这样如果有人遇到类似的问题,它可能会有所帮助。