Android: Leave one activity running when page is called multiple times

I have multiple pages branching of a title page, and when a back button is pressed on the branch pages it recalls the title page with:

Intent backIntent = new Intent(Options.this, TitlePage.class);
        Options.this.startActivity(backIntent);

Then destroys with:

protected void onPause() {
    super.onPause();
    finish();
}

The problem is each time this is called it overlays the title page. I need only one title page to exist without destroying all of them with the finish() method.

Answers


Use

bachIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

If you want your branching activities to go back to the title activity no matter how far down the tree the user goes, you should call those activities with the noHistory flag. That way, anytime the child activities are finished, the user will always end up back at the title activity.

This can be done two ways:

With the Intent used to launch the Activity:

Intent myIntent = new Intent();
myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(this, myIntent);

In the Android Manifest file (AndroidManifest.xml):

<activity
    android:name="com.logitech.squeezebox.activities.HomeActivity"
    android:label="@string/app_name"
    android:noHistory="true" />

Need Your Help

change tint and background colors of a ABPeoplePickerNavigationController embedded in a tab bar view controller

ios objective-c abpeoplepickerview

i have a tab bar controller in witch i would like to embed a ABPeoplePickerNavigationController. I' done so by putting this code in viewDidLoad

carry (cache?) web elements over to new pages as they load

javascript jquery html css

Wondering if there's a way to animate a div containing an image while a new page loads behind the animation (probably using jQuery, but not sure if there's an easier way).