简体   繁体   中英

Android Back Stack in fragments

Hi i an Question on BackStack, 在此处输入图片说明

in screen it should not back back from 3 to 2 screen on clicking back button on Android phone.

but inside the 3 screen , first it will show home screen , then book and atlast xyz

when e clik back in 3 screen it came to from xyz to books screen then to home screen finaly it should not go back to 2 screen .

fragmentManager.beginTransaction()add(R.id.frame_container,fragment).addToBackStack(null).commit();

Username and password is Activity ,

3-screen is FragmentActivty

When you are done with password activity.. you can simply add finish() statement before startActivity(Home) in this case it will be removed from the BackStack and when pressing back it will exit you from the application

so it should be something like this:

Intent i = new Intent(this, ..homeActivity.class);
finish();
startActivity(i);

same goes for username activity if you don't want to get back to it

If you do not want to retain the activities or fragment activities in backstack use noHistory in activity tag of your menifest.

    <activity
        android:name="YourActivityName"
        android:label="@string/app_name"
        android:noHistory="true" >
    </activity>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM