back-stack

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

天大地大妈咪最大 提交于 2019-12-04 16:03:37
问题 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. 回答1: 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

Go back to different Activity in back stack in Android

这一生的挚爱 提交于 2019-12-04 12:43:19
Say I have an activity stack as such: A -> B -> C -> D I would like to create a new activity "E", and end up with a stack like this: A -> B -> E Basically, upon hitting the back button in activity D, I need to swap out activity C for activity E, and land on it. Is this possible? Or should I be structuring the navigation differently somehow? Thanks! so while going from activity C to D finish(); C activity. At last at backPress method of Activity D call activity E and finish(); Activity D 来源: https://stackoverflow.com/questions/49126438/go-back-to-different-activity-in-back-stack-in-android

Intent.FLAG_ACTIVITY_CLEAR_TOP not working

自闭症网瘾萝莉.ら 提交于 2019-12-04 08:23:17
My Application Flow: Login->Profile->UpdateProfile->ChangePass All of my activitys extends FragmentActivity When I press button in ChangePass Activity I call this code: Intent intent=new Intent(getApplicationContext(),LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); So It should start LoginActivity and when I press back from LoginActivity then Application should close...But When I press back button from Login Activity the flow is: ChangePass->UpdateProfile->Profile->Login Why My back stack is not cleared ? Note: I have applied all these solutions

How to exclude from recents an exported activity?

倖福魔咒の 提交于 2019-12-04 07:27:21
I have an app with an exported activity that can be invoked from other apps (Specifically the sharing action - android.intent.action.SEND ) How can an exported activity be excluded from recents? I don't see a way to set the FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag, because it is invoked from the outside. The reason I want to do this is because this intent becomes the last one in my activity stack, thus when clicking on the recents, a file is being re-shared instead of the main activity to pop up. Note : android:launchMode="singleTask" solves the problem in a specific case, only where another

Android back-stack not being created from Notification PendingIntent

有些话、适合烂在心里 提交于 2019-12-04 06:26:47
I'm having issue if the app isn't in memory when the notification is followed. The backstack won't be created. I've followed the steps according to the developers guide. Please show me the bit I've missed otherwise I'll have to route all intents through my HomeActivity in order to create the backstack manually on following intent. AndroidManifest.xml : <activity android:name=".activity.HomeActivity" android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboard|keyboardHidden|screenSize" android:icon="@drawable/actionbar_logo" android:label="@string/activity_label_home" android

Resume the Activity instead of Starting if already exists in back stack

≡放荡痞女 提交于 2019-12-03 18:32:56
问题 I have an Activity_1 after a lot of steps, say Activity_2 > Activity_3 .... in some Activity_n I change some data related to Activity_1 and call it using Intent intent = new Intent(Activity_n.this, Activity_1.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); To refresh the content. But later I can go all the way back to Activity_1 where I started, which has old data. Instead I want the initial Activity_1 ' s onResume() to be called, using the above code. Or

Get all fragments from backstack in order

久未见 提交于 2019-12-03 16:28:43
I am using Fragments in my app project. All the fragments are added to back stack : ... fragmentTransaction.addToBackStack(null); ... Later on, what is the correct way to get all fragments from back stack in order ? Using the getBackStackEntryCount() you can iterate through the back stack and use the getBackStackEntryAt() method to get each Fragment. EDIT: Based on some discussions in the comments, it is advised that you manually store a list of the Fragments you have added to your backstack, and persist these into your SharedPreferences. You can then read this list back when the application

Fragment's onResume() not called when popped from backstack

杀马特。学长 韩版系。学妹 提交于 2019-12-03 15:33:26
问题 Hi I am developing android application in which I am using I am using single Activity and 3 fragments. So consider I have 3 fragments A B C. When I switch from A to B, I am adding Fragment to backstack and simillar for B to C. Now when I click back from C it shows me B and similar for B to A as well. But thing is that when I come from C to B or B to A, it's not calling onResume() or any other life cycle methods of Fragment . What I want to do actually for every Fragment I have different title

noHistory vs finish() - Which is preferred?

混江龙づ霸主 提交于 2019-12-03 14:59: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

How can I save the application back stack to a bundle?

一世执手 提交于 2019-12-03 14:27:38
I'd like to save the state of my application so that when it is reopened from a closed state, the last fragment is visible and the back stack is preserved. I'd like to preserve this state every time the application is closed, not just on an orientation change or when the system kills the app to free up resources (as is the case when using onSaveInstanceState() / onRestoreInstanceState() . So far I've been able to restore the previous fragment and its state as planned by saving the state to SharedPreferences and restoring it later. However, this does not preserve the fragment back stack, so