Question

I have a notification that, when clicked, takes the user to my app's preferences menu. That menu also has a nested PreferenceScreen. What I'm trying to accomplish is: when the notification is clicked, it brings the user to the nested PreferenceScreen.

Is this possible? Here's what I currently have (gets me to the main preferences menu):

PendingIntent intent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), MyPreferencesActivity.class), 0);
Was it helpful?

Solution

Take a look al this answer. You will need to add an extra to your intent to indicate which PreferenceScreen should be opened, then use the method described there to 'simulate' a click in the preference.

Actually, if your are using the new API with PreferenceFragment, PreferenceHeader and whatnot, the class PreferenceActivity already does all that for you. Just put the name of the PreferenceFragment you want opened in the EXTRA_SHOW_FRAGMENT extra.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top