activity-stack

Clear activity stack in android

不问归期 提交于 2019-12-03 21:54:04
I have a LoginActivity as my launcher screen. And SettingsActivity as my fifth screen . I have a logout button in settings screen. On clcik of this button, how can i go to Screen-1 (i.e LoginActivity) by clearing all remaining activities (i.e 2nd, 3rd, 4th) from activity stack? Note : i have finished LoginActivity but not remaining activities. Thanks in advance Simple, set an onclick on your logout button and then add this to your intent: Intent newIntent = new Intent(this, login.class); newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(newIntent); finish(); This should clear

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

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

How to see the activity stack in debug?

扶醉桌前 提交于 2019-12-03 03:09:11
I have a problem that one of my activities is popping out after I think I finished it. Is there a way to see the stack of the activities? hasanghaforian 1-You can use Hierarchy Viewer within Eclipse .You can see all connected devices and emulators and the activity stack . And in addition in the tree view you can see much more information about the view itself: 2-From the command line , you can use this: adb shell dumpsys activity .This asks the activity manager to print a dump of its current state. The first part of that is the complete activity history, organized by task. You can see more

what is the right way to clear background activity/activites from stack?

旧时模样 提交于 2019-12-01 01:08:49
as the questions title says - I need to know what is the best way to "remove"/destroy/finish an activity that are somewhere in the middle of stack and currently on pause mode (not specific instances - but specific derived classes). for example: if the current state of the stack looks like this: ActivityD <-- top of the stack, currently forground ActivityC ActivityA ActivityC ActivityA a request to "clear" all ActivityC instances would cause the stack to be like: ActivityD <-- still top of the stack, currently forground. ActivityA ActivityA I don't want to do that depends on activity launch

how to finish all activities and close the application in android?

回眸只為那壹抹淺笑 提交于 2019-11-30 17:25:24
My application has the following flow: Home->screen 1->screen 2->screen 3->screen 4->screen 5>Home->screen 2->Home->Screen 3 My problem is that when I am trying to close the application then Home activity opens everytime when I am trying to close the application. I just want to close the application when user presses the back key of device on home screen. Ragaisis There is finishAffinity() method that will finish the current activity and all parent activities, but it works only in Android 4.1 or higher. Loi Ho This works well for me. You should using FLAG_ACTIVITY_CLEAR_TASK and FLAG_ACTIVITY

How to find back stack activities in an android application?

梦想的初衷 提交于 2019-11-30 11:29:44
问题 I have an application with activities back stack A -> B -> C -> D -> E. Now at activity E, I want to know the back stack activities that I navigated from. How do I find this?? 回答1: The code below can be used to extract all the tasks and the top activity within each task in the back stack ActivityManager m = (ActivityManager) ctx.getSystemService( ctx.ACTIVITY_SERVICE ); List<RunningTaskInfo> runningTaskInfoList = m.getRunningTasks(10); Iterator<RunningTaskInfo> itr = runningTaskInfoList

How to find back stack activities in an android application?

百般思念 提交于 2019-11-30 01:03:14
I have an application with activities back stack A -> B -> C -> D -> E. Now at activity E, I want to know the back stack activities that I navigated from. How do I find this?? The code below can be used to extract all the tasks and the top activity within each task in the back stack ActivityManager m = (ActivityManager) ctx.getSystemService( ctx.ACTIVITY_SERVICE ); List<RunningTaskInfo> runningTaskInfoList = m.getRunningTasks(10); Iterator<RunningTaskInfo> itr = runningTaskInfoList.iterator(); while(itr.hasNext()){ RunningTaskInfo runningTaskInfo = (RunningTaskInfo)itr.next(); int id =

onCreate always called if navigating back with intent

浪尽此生 提交于 2019-11-29 10:10:22
I have an activity called HomeActivity that has a SurfaceView and shows a camera preview picture. This activity is quiet heavy and feels slow if you are starting/restarting it. So I made some investigations and found out, that somehow always the onCreate method is being called. In my opinion this should not happen if the Activity has already been started? The documentation says : Called when the activity is first created. This is where you should do all of your normal static set up: create views, bind data to lists, etc. This method also provides you with a Bundle containing the activity's

How to Control Android back stack

痴心易碎 提交于 2019-11-28 10:24:00
Lets say I have A->B->C->D->E In android back stack. I want to be able to get back to one of the following: A->B->C A->B A How can I achieve this? Hopefully without forcing back button clicks. Using the image and information from the official developers page on Android tasks and back stack you can see that of all other ways to launch an Activity you can ensure such behavior only using the FLAG_ACTIVITY_CLEAR_TOP in your Intent flags. Your regular back button proceeds as: But when you specify this flag, you get a behavior like you need, as given by an example at this source : consider a task