0

I'd like to kill all activities when the user hits the back button and returns to my main activity A. My App has the following 3 activities:

A -> Displays users selections before they hit search and creates activity B.
B -> Displays a list of urls's based on the users selection and creates activity C.

C -> Opens a Webview and displays the page selected by the user.

Currently, i don't call finish() after starting activity B so when the user hits the back button in activity C they can return to the list of url's and make another selection if they want.

I'd like to create a new activity A (without the users initial selections) and ensure the existing activities B and C are killed if the user hits the back button in activity B?

Any help would be appreciated.

Thanks

O.

user676567
  • 1,119
  • 9
  • 20
  • 39

1 Answers1

0

You can return to activity A by overriding the back button handler in activity C and launching activity A with the flag FLAG_ACTIVITY_CLEAR_TOP set, or alternatively (perhaps preferably in your case), you can just set noHistory for your activity B.

You'll have to reset activity A manually in some way in this case though.

kabuko
  • 36,028
  • 10
  • 80
  • 93
  • Hi, thanks for your response. I'm assuming you meant overriding the back button in activity B? I tried the following from activity B but its not working? `public void OnBackPressed(){ Intent setIntent = new Intent(this,A.class); setIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(setIntent); super.onBackPressed(); }` – user676567 Mar 12 '12 at 07:37