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

6
  • Please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 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. Commented Sep 4, 2018 at 9:15
  • oh,Sorry about it. I don't know about as I'm new to stack overflow and this is my first question. Commented Sep 4, 2018 at 9:24
  • Possible duplicate of Can't get WRITE_SETTINGS permission Commented Sep 4, 2018 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. Commented Sep 5, 2018 at 4:23
  • 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. Commented Feb 8, 2019 at 19:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.