In my code I have:
Settings.System.putInt(this.getContentResolver(), "vibrate_when_ringing", isVibrateWhenRinging ? 1 :0);
Using the following permission:
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
This was working fine from Jelly Bean (API 16) till Lollipop (API 22).
In Android M, I know that for using that permission I need to prompt the user to Settings.ACTION_MANAGE_WRITE_SETTINGS.
However, even with that permission turned on, I see the following error:
E/AndroidRuntime: java.lang.IllegalArgumentException: You cannot change private secure settings.
E/AndroidRuntime: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
E/AndroidRuntime: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
E/AndroidRuntime: at android.content.ContentProviderProxy.call(ContentProviderNative.java:646)
Well... Am I missing something? With proper permissions we can change ringtones, do not disturb mode, etc. But it also looks like that with Android M we won't be able to change such a normal setting like "Vibrate when ringing". I hope I'm wrong.