back-stack

Clearing the full Android activity stack on older SDKs (that lack FLAG_ACTIVITY_CLEAR_TASK)

ぐ巨炮叔叔 提交于 2019-11-27 04:28:29
问题 I've done qui a bit of reading and searching on SO, but can't find a way to clear the current activity stack . The context of my app is an activity started by a a background service / notification. Imagine that my app allows you to organise a list of people. A few hours ago, you were viewing person X in the "View" activity, that's now the top of your stack. At some point in the future, the service triggers and I popup a new "Notify" activity for person Y . From there you can edit person Y's

How to Reverse Fragment Animations on BackStack?

只谈情不闲聊 提交于 2019-11-27 04:14:04
问题 I thought the system would reverse animations on the backstack when the back button is pressed when using fragments using the following code: FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.setCustomAnimations(R.anim.slide_in, R.anim.hyperspace_out); ft.replace(R.id.viewContainer, new class(), "layout").addToBackStack(null).commit(); 回答1: According to the android documentation for custom animation: Change: ft.setCustomAnimations(R.anim.slide_in, R

PopBackStack but keep the first fragment in android

青春壹個敷衍的年華 提交于 2019-11-27 03:55:45
问题 I am working on fragment transaction, and the backstack is like this: fragA => fragB => fragC => fragD I would like to return to fragA after back fromn the fragD fragD => onBackPress => fragA So, I tried code like: getChildFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); but it clear all the backstack , how can I keep the first fragment in the backstack? Thanks a lot 回答1: E.g. you can do following: add fragA without adding it to backStack. So it always be in

How to pop fragment off backstack

限于喜欢 提交于 2019-11-27 03:31:21
I have an activity A, which calls fragment Bf, which calls fragment Cf. I want Bf to be placed in the backstack when Cf is called so that users can navigate back to it. However, if a specific button is pressed in Cf, I would like Bf to be removed from the backstack. Is this possible? I see that there is a popBackStack() function. However, I am a little confused on how this would work. Is it safe to use this function? Is there any possibility that an activity from a different application would be inserted after Bf on the backstack? Also, is there any way to alter the savedInstanceState of the

get the latest fragment in backstack

纵饮孤独 提交于 2019-11-27 02:59:53
How can I get the latest fragment instance added in backstack (if I do not know the fragment tag & id)? FragmentManager fragManager = activity.getSupportFragmentManager(); FragmentTransaction fragTransacion = fragMgr.beginTransaction(); /****After add , replace fragments (some of the fragments are add to backstack , some are not)***/ //HERE, How can I get the latest added fragment from backstack ?? Deepak Goel You can use the getName() method of FragmentManager.BackStackEntry which was introduced in API level 14. This method will return a tag which was the one you used when you added the

How to run an activity only once like Splash screen

浪子不回头ぞ 提交于 2019-11-27 02:54:50
问题 In my app, I would like to run the Splash screen once at first run only but the problem is that I already placed in the Manifest this line: android:noHistory="true" which works great if I press back button and exits the app but note that the app is still in the background running, and when I press the app icon it goes back again to the Splash screen then my Registration page. I wanted to be redirected to the Registration page directly when I reopen my application. How do I do this? Thanks

Fragment addToBackStack() and popBackStackImmediate() not working

拜拜、爱过 提交于 2019-11-27 01:30:53
问题 I am currently building an application for Android (14 <= SDK <= 21) by using one ActionBarActivity and more Fragments , such as ListFragment and MapFragment , which are swapped within a single FrameLayout view. The ActionBarActivity automatically replace/commit fragment A. Then, when the user tap a button, the hosting Activity replace/commit a new different fragment B. My goal is to let the user go back on fragment A as soon as she presses the back button. Some code now. MainActivity public

Android - save/restore fragment state

眉间皱痕 提交于 2019-11-26 17:28:27
I have an Activity in which I go through several fragments. In every fragment I have several views ( EditText, ListView, Map , etc). How can I save the instance of the fragment that is shown at that moment? I need it to work when the activity is onPause() --> onResume() . Also I need it to work when I return from another fragment (pop from backstack). From the main Activity I call the first fragment, then from the the fragment I call the next one. Code for my Activity: public class Activity_Main extends FragmentActivity{ public static Fragment_1 fragment_1; public static Fragment_2 fragment_2;

Android: Remove all the previous activities from the back stack

爱⌒轻易说出口 提交于 2019-11-26 17:09:56
When i am clicking on Logout button in my Profile Activity i want to take user to Login page, where he needs to use new credentials. Hence i used this code: Intent intent = new Intent(ProfileActivity.this, LoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); in the onButtonClick of the Logout button. But the problem is when i click device back button on the Login Activity it takes me to the ProfileActivity. I was expecting the application should close when i press device back button on LoginActivity. What

Fragments onResume from back stack

[亡魂溺海] 提交于 2019-11-26 15:03:00
I'm using the compatibility package to use Fragments with Android 2.2. When using fragments, and adding transitions between them to the backstack, I'd like to achieve the same behavior of onResume of an activity, i.e., whenever a fragment is brought to "foreground" (visible to the user) after poping out of the backstack, I'd like some kind of callback to be activated within the fragment (to perform certain changes on a shared UI resource, for instance). I saw that there is no built in callback within the fragment framework. is there s a good practice in order to achieve this? oriharel For a