4

My application settings can be opened and closed with hardware menu button (as well as with back button when navigating out of the root screen). There are many child screens in this preferences. (And lets say, there are two activities - main and settings).

I'd like that I could return to the last preference screen I was working with when I access application settings again.

Saving last preferenceScreen key and using setPreferenceScreen(lastPreferenceScreenKey) is not relevant as in this case I can't navigate up the hierarchy.

Setting PreferenceActivity.launchMode="singleTask" and starting main activity when user presses menu button didn't help - when I starting settings activity again Its root screen appears.

Is it possible somehow or another?

moorka
  • 533
  • 4
  • 8

2 Answers2

0

Maybe try to use a back button pressed listener:

    @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        // Back button pressed
    }
    return super.onKeyDown(keyCode, event);
}
tim687
  • 2,256
  • 2
  • 17
  • 28
0

Try to use sharedPreference for storing last visited screen and use a dispatcher activity to dispatch to the correct activity based on the preference on launching the application.

Refer this link for your reference .

Community
  • 1
  • 1