back-stack

How can I maintain fragment state when added to the back stack?

怎甘沉沦 提交于 2019-11-26 03:02:26
问题 I\'ve written up a dummy activity that switches between two fragments. When you go from FragmentA to FragmentB, FragmentA gets added to the back stack. However, when I return to FragmentA (by pressing back), a totally new FragmentA is created and the state it was in is lost. I get the feeling I\'m after the same thing as this question, but I\'ve included a complete code sample to help root out the issue: public class FooActivity extends Activity { @Override public void onCreate(Bundle

How to prevent multiple instances of an Activity when it is launched with different Intents

99封情书 提交于 2019-11-26 01:55:50
问题 I\'ve come across a bug in my application when it is launched using the \"Open\" button on the Google Play Store app (previously called Android Market). It seems that launching it from the Play Store uses a different Intent than launching it from the phone\'s application menu of icons. This is leading to multiple copies of the same Activity being launched, which are conflicting with each other. For example, if my app consists of the Activities A-B-C, then this issue can lead to a stack of A-B

Clear the entire history stack and start a new activity on Android

守給你的承諾、 提交于 2019-11-26 01:37:14
问题 Is it possible to start an activity on the stack, clearing the entire history before it? The situation I have an activity stack that either goes A->B->C or B->C (screen A selects the users token, but many users only have a single token). In screen C the user may take an action which makes screen B invalid, so the application wants to take them to screen A, regardless of whether it is already in the stack. Screen A should then be the only item on the stack in my application. Notes There are

How to resume Fragment from BackStack if exists

孤人 提交于 2019-11-25 23:32:57
问题 I am learning how to use fragments. I have three instances of Fragment that are initialized at the top of the class. I am adding the fragment to an activity like this: Declaring and initializing: Fragment A = new AFragment(); Fragment B = new BFragment(); Fragment C = new CFragment(); Replacing/Adding: FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.content_frame, A); ft.addToBackStack(null); ft.commit(); These snippets are working properly. Every