0

I am making a settings page for an app and one of the features I want is for the user to change the permissions through the settings page by redirecting to the users phones settings. I am trying to figured out how to do that programmatically. I am wondering if it can be done like the same way as android.intent.action.VIEW through the preference like I show in the example or is there a different procedure I have to follow.

<Preference android:title="Example">
    <intent android:action="android.intent.action.VIEW"
            android:data="https://example.com/" />
</Preference>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • 2
    Hi, welcome to Stack Overflow! Take a look at [this question](https://stackoverflow.com/a/19517448/9420243), I think it has what you're looking for – Matthew Schlachter Apr 09 '18 at 19:14

1 Answers1

0

You can use onSharedPreferenceChanged Listener for this purpose !

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    // get the preference that has been changed
    Preference selectedPreference= findPreference(key);
    Object changedPreference = selectedPreference;
  //  Log.d("CHECK",selectedPreference.getTitle().toString());

    // and if it's an instance of EditTextPreference class, update its summary
    if (selectedPreference instanceof EditTextPreference) {
         //Do your stuff 
    }

}
MezzDroid
  • 560
  • 4
  • 11