back-stack

TabLayout ViewPager Not Loading When Using Backstack [duplicate]

。_饼干妹妹 提交于 2019-12-03 14:21:49
This question already has an answer here: Lifecycle of a replaced ViewPager and BackStack? 1 answer I'm using a TabLayout in one of my fragments with a viewPager to switch between two fragments below the tabs. When I click the FAB inside one of the lower fragments, I load a new fragment (for input). However- when I press the BACK button, the TabLayout shows up but WITHOUT either of the lower fragments (represented by the pages). So what am I doing wrong? and is there a better way to be swapping fragments ? and is there a way to press the back button and get back to the viewPager Page that was

Android : Return to previous fragment on back press

我是研究僧i 提交于 2019-12-03 10:02:07
I have implemented Navigation Drawer which is a subclass of Activity. I have many fragments in my application. My question goes here Imagine there are 3 fragments : Fragment_1 : Fragment_2 : Fragment_3 When I start my application, Fragment_1 is loaded When I click on some components on Fragment_1, I'm navigated to Fragment_2 and so on.. So it's like Fragment_1 > Fragment_2 > Fragment_3 When I press back key from Fragment_2, I'm navigated back to Fragment_1 But when I press back key from Fragment_3, I'm navigated back to Fragment_1 (instead of Fragment_2) I want something like this in my

How to Prevent Accidental App Exit w/in Android Fragments/Activities?

我的未来我决定 提交于 2019-12-03 09:16:00
How Do I Prevent Accidental App Exit w/in Android? IE: When the he/she presses the back button and reaches the last activity in the BackStack, show a toast to ask if the user wants to exit using the onBackPressed() method. Also, It needs to function with backStacks for fragments. This functionality can easily be implemented by overriding main activity's onBackPressed() method. In this example when user presses back button then the app will display a toast for 4 seconds on which time a new back press terminates the app immediately. ref You can put it in a BaseActivity that extends Activity like

print the current back stack in the log

丶灬走出姿态 提交于 2019-12-03 09:14:49
问题 Is there a way to print the current back stack of the current task in an Android app? In particular, I want to understand when an activity is popped off the stack after its onDestroy() is called. 回答1: You can use adb for this: adb shell dumpsys activity 回答2: To improve on Paul's answer and see data relevant to your app only you can do: adb shell dumpsys activity package <your.package.name> 回答3: Use the command below can show tasks and activity backstack adb shell dumpsys activity activities |

Fragment PopBackStack

£可爱£侵袭症+ 提交于 2019-12-03 06:53:52
问题 I am getting a strange problem, while using Fragments and popping back them out. I have one Fragment Activity: Step1: I am attaching one Fragment in the onCreate of that Activity in the Starting named Fragment A as: This is the onCreate of Fragment Activity @Override protected void onCreate(Bundle savedBundleState) { super.onCreate(savedBundleState); setContentView(R.layout.activity_base_new); Fragement_Home home = new Fragement_Home(); FragmentManager manager = getSupportFragmentManager();

noHistory vs finish() - Which is preferred?

你说的曾经没有我的故事 提交于 2019-12-03 05:36:00
I don't want my application to show few Activity (say SplashScreenActivity ) when pressing back button. So I've used noHistory=true in my Manifest.xml for that Activity as show below: <activity android:name="com.gokul.SplashScreenActivity" android:noHistory="true" > </activity> Instead of setting noHistory , I can also call finish() in my SplashActivity.onPause() method or wherever I want, as shown below: @Override protected void onPause() { super.onPause(); finish(); } Both does the job perfectly. But which one is better to use, to use noHistory or call finish() ? onPause() is not at all a

savedInstanceState when restoring fragment from back stack

我怕爱的太早我们不能终老 提交于 2019-12-03 05:30:13
问题 Can I use savedInstanceState() to save the state when removing a fragment, then restore the state when I pop the fragment off the back stack? When I restore the fragment from the back stack, savedInstanceState bundle is always null. Right now, the app flow is: fragment created -> fragment removed (added to back stack) -> fragment restored from back stack (savedInstanceState bundle is null). Here is the relevant code: public void onActivityCreated(Bundle savedInstanceState) { super.onCreate

How to replace fragment C with fragment A when back button is pressed?

大兔子大兔子 提交于 2019-12-03 01:56:50
问题 My scenario : Activity 1 consists of Fragments A-> B-> C. All the fragments are added using this code : FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.content, fragment, TAG); ft.addToBackStack(TAG); ft.commit(); Now, from fragment C, I want to directly return to Fragment A. Therefore, I've commented ft.addToBackStack(TAG) while adding Fragment C. So when I press back button from C I directly get Fragment A on the screen.

Fragment PopBackStack

走远了吗. 提交于 2019-12-02 20:32:36
I am getting a strange problem, while using Fragments and popping back them out. I have one Fragment Activity: Step1: I am attaching one Fragment in the onCreate of that Activity in the Starting named Fragment A as: This is the onCreate of Fragment Activity @Override protected void onCreate(Bundle savedBundleState) { super.onCreate(savedBundleState); setContentView(R.layout.activity_base_new); Fragement_Home home = new Fragement_Home(); FragmentManager manager = getSupportFragmentManager(); manager.beginTransaction().add(R.id.frameContent, home).addToBackStack("home").commit(); } Step:2 After

savedInstanceState when restoring fragment from back stack

梦想与她 提交于 2019-12-02 18:48:10
Can I use savedInstanceState() to save the state when removing a fragment, then restore the state when I pop the fragment off the back stack? When I restore the fragment from the back stack, savedInstanceState bundle is always null. Right now, the app flow is: fragment created -> fragment removed (added to back stack) -> fragment restored from back stack (savedInstanceState bundle is null). Here is the relevant code: public void onActivityCreated(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle bundle = getArguments(); Long playlistId = bundle.getLong(Constants.PLAYLIST