3

In my app even after user allowing modify system settings (write_settings) permission, the permission in real is not granting to my app.

User allowed allow modify settings:

User allowed allow modify settings pic

but, when I went into settings > installed apps> my app > other permissions in order to check granted permissions, Modify system setting permission for my app is being denied.

Modify system settings permission denied pic

I have added write settings permission in manifest file

 <uses-permission android:name="android.permission.WRITE_SETTINGS" />

and also I used the code to open settings intent

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
            boolean settingsCanWrite = Settings.System.canWrite(getContext());
            if(!settingsCanWrite){

                showWriteSettingsDialog();

            }
        }
private void showWriteSettingsDialog(){

    final Dialog dialog = new Dialog(getContext());
    LottieAnimationView animation_view = dialog.findViewById(R.id.animation_view);
    dialog.setContentView(R.layout.write_settings_dialog);
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    button = dialog.findViewById(R.id.write_settings_button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
            intent.setData(Uri.parse("package:" + getContext().getPackageName()));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivityForResult(intent,CODE_WRITE_SETTINGS_PERMISSION);
        }
    });
    dialog.show();

}

It's working on other devices I have tested but not working in Xiaomi's MIUI devices. If possible please provide me with a work around. I desperately needed this permission as my app want to change ringtones. Answers in this link(Can't get WRITE_SETTINGS permission already implemented but not working in xiaomi devices

Harsha pulikollu
  • 2,386
  • 15
  • 28
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Sep 04 '18 at 09:15
  • oh,Sorry about it. I don't know about as I'm new to stack overflow and this is my first question. – Harsha pulikollu Sep 04 '18 at 09:24
  • Possible duplicate of [Can't get WRITE\_SETTINGS permission](https://stackoverflow.com/questions/32083410/cant-get-write-settings-permission) – Marcos Vasconcelos Sep 04 '18 at 14:25
  • @MarcosVasconcelos I already implemented in the same way and it's working in all other devices, but not in xiaomi's MIUI OS based devices. That's why I specifed it in question itself. – Harsha pulikollu Sep 05 '18 at 04:23
  • Agree, there are some strange reasons why it doesn't work as intended on MIUI 9+ – Gaket Sep 18 '18 at 18:48
  • 1
    There are two "Modify system settings" permission windows on MIUI 9+. First one is accessible from phone settings but it doesn't have any effect. Second one is hidden but I couldn't find its shortcut. Nova launcher use that second window when it is asking for permission to lock screen. – sevenkul Feb 08 '19 at 19:17

0 Answers0