Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android go back to first screen

I have an android app with links (made by linkify) that lead into other screens of my app. I'm wondering what's the best approach to close all of the 'child' activities and go back to the first activity that was originally launched.

in otherwords something like this:

HomeScreenActivity => Screen1 (via Linkify-link) => Screen2 => Screen3 => click home => (close screens 1, 2 & 3) => HomeScreenActivity

like image 569
Ben Avatar asked Jul 26 '10 18:07

Ben


People also ask

How do I get my android back to the main screen?

To return to the Home screen, swipe upwards or downwards on the Apps screen. Alternatively, tap the Home button or the Back button.

How do I go back to first activity on Android?

Declare A in your manifest with the android:launchMode="singleTask" . This way, when you call startActivity() from your other activies, and A is already running, it will just bring it to the front. Otherwise it'll launch a new instance.


1 Answers

You should be able to accomplish this by creating an intent for your HomeScreenActivity with the FLAG_ACTIVITY_CLEAR_TOP flag.

like image 59
Cheryl Simon Avatar answered Oct 07 '22 03:10

Cheryl Simon