1

I have the following code to change the system accent color:

fun sendMessage(view: View){
    val cr = applicationContext.contentResolver
    putInt(cr, "accent_color", "-8270158")
}

And canWrite(applicationContext) returns true.

My Manifest.xml already has:

 <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"
    tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"
    tools:ignore="ProtectedPermissions" />

And I've used adb to grant WRITE_SECURE_SETTINGS and native settings to "Modify System Settings". I'm still getting this error:

java.lang.IllegalArgumentException: You cannot change private secure settings.

I can use adb to change the accent_color using

adb shell settings put system accent_color -8270158

I also tried using shell scripts through Kotlin but they didn't work either. My project uses API 16 and testing device is Android 11.

0 Answers0