Android :: How To Clear Stack Back To Root Activity When User Leaves Application?

Jan 25, 2010

I have an application with 2 activities, LogonAct and MainAct. LogonAct is a logon activity which I want to force the user to go through each time they return to the application. I've set android:clearTaskOnLaunch="true" on LogonAct.

Android :: How to clear stack back to root activity when user leaves application?


Android :: On Logout Clear Activity History Stack Preventing Back Button

Jun 9, 2010

All activities in my application require a user to be logged-in to view. Users can log out from almost any activity. This is a requirement of the application. At any point if the user logs-out, I want to send the user to the Login Activity. At this point I want this activity to be at the bottom of the history stack so that pressing the "back" button returns the user to Android's home screen.

I've seen this question asked a few different places, all answered with similar answers (that I outline here), but I want to pose it here to collect feedback. I've tried opening the Login activity by setting its Intent flags to FLAG_ACTIVITY_CLEAR_TOP which seems to do as is outlined in the documentation, but does not achieve my goal of placing the Login activity at the bottom of the history stack, and preventing the user from navigating back to previously-seen logged-in activities. I also tried using android: launchMode ="singleTop" for the Login activity in the manifest, but this does not accomplish my goal either (and seems to have no effect anyway). I believe I need to either clear the history stack, or finish all previously- opened activities. One option is to have each activity's onCreate check logged-in status, and finish() if not logged-in. I do not like this option, as the back button will still be available for use, navigating back as activities close themselves. The next option is to maintain a LinkedList of references to all open activities that is statically accessible from everywhere (perhaps using weak references). On logout I will access this list and iterate over all previously-opened activities, invoking finish() on each one. I'll probably begin implementing this method soon.

I'd rather use some Intent flag trickery to accomplish this, however. I'd be beyond happy to find that I can fulfill my application's requirements without having to use either of the two methods that I've outlined above. Is there a way to accomplish this by using Intent or manifest settings, or is my second option, maintaining a LinkedList of opened activities the best option? Or is there another option that I'm completely overlooking?

View 2 Replies View Related

Back Up Database When User Click Clear Data In Manage Application?

Sep 20, 2012

i build application....and i want to back up my database when user click "clear data" in manage application... because data is lost...some data is very critical for process in my application...how can i solved this?

View 2 Replies View Related

Android :: How To Clear Activity Stack If Using Same Activity Multiple Times?

Mar 3, 2010

So I have an app with Activity A. The layout on the activity is dynamic genearted. So it's possible that on Activity A a user hits a button that goes to "A" and the new page looks different, then a user clicks another button to go to "A" again. Now I have 2 Activities in the history stack. A, A, and currently on A. Is it possible that if a user clicks a button that the whole Activity stack is cleared in a scenario such as this?

View 5 Replies View Related

Android :: How To Clear All Activity In Stack Below Latest Activity?

Dec 22, 2009

All the current discussions involves clearing all activites above an existing activyt, but I'm trying to find a way to clear all the activities before the latest activity in the stack. So my scenario is A -> B -> C and then when a user goes to Activity D, activies A,B,C should be cleared from the activity stack. FLAG_ACTIVITY _CLEAR_TOP seems to only clear any activites above an existing activity. Anybody run into this scenario and found a solution?

View 4 Replies View Related

Android :: Clear Activity Stack And Replace With A New Activity

Sep 17, 2009

i want to clear the activity stack and replace it with a new activity as the root activity, even if that activity exists somewhere on the stack (or not). i see FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_NEW_TASK, but it's not obvious to me how to use those in conjunction to achieve what I want. it's like i want to completely restart the task with some activity that i specify as the new root.

View 9 Replies View Related

Android :: Clear Activity Stack?

Nov 3, 2009

Is there a way to clear our Activity stack? For example, a user in my app progresses through these activities, one is launched from the previous activity: ActivityA -> ActivityB -> ActivityC if the user is now looking at ActivityC, and they hit the back button, they will go back to ActivityB. Is it possible to add a menu to ActivityC where the user can clear their activity stack, and then launch a new instance of ActivityA? This would be so the user can jump to a particular activity in my application without getting confused with the back button + history,

View 4 Replies View Related

Android :: How To Clear Activity Stack In Task

Jan 6, 2010

I have three activities. Activity A start activity B by the method startActivityForResult, and Activity B start activity C by the method startActivity. Then, after starting activity C, activity B kill himself by finish(). Now the task stack stored two activities: A and C. My question is: how can I finish activity A when I finish activity C. or how can I clear the whole stack of the task.

View 5 Replies View Related

Android :: Make A Particular Activity As A Root Activity In Stack

Aug 4, 2009

i have a set of activities on my stack Say A-->B-->C. when i launch the activity named 'D' it should get fired as the root activity of my application and all the other activities(A,B,C) should get cleared from my stack once Activity D is launched.Can any one tell me as how to do this

View 4 Replies View Related

Android :: Clear Entire History Stack And Start A New Activity On Android

Aug 13, 2010

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 many other similar questions, but I haven't found anything that answers this exact question. I tried calling getParent().finish() - this always results in a null pointer exception. FLAG_ACTIVITY_CLEAR_TOP only works if the activity is already on the stack.

View 1 Replies View Related

Android :: Any Way To Go 2 Steps Back In Activity Stack?

Apr 7, 2010

Android - Can I force BACK button to go 2 steps back in the Activity stack with some kind of code? I know I can override the onKeyDown method but I want BACK to do it's thing, just twice!

View 3 Replies View Related

Android :: How To Manipulate Activity Back Stack?

Nov 22, 2010

I want to implement the following logic. I have 4 activites A, B, C and D. The flow is A -> B -> C -> D When the user navigates from A -> C he should be able to get back to the previous activities by pressing the back button. But after reaching D pressing the back button should take him to activity A. And pressing the back button againg should exit the application instead of taking him back to B / C / D. How do I do it.

View 1 Replies View Related

Android :: How To Clear Activity From Second Activity Going Back To Home Screen?

Mar 3, 2010

example scenario is: from login screen - main screen - then when i clicked a hide button the app will go to home screen, and when im going to click the app again the main screen would be called.

View 2 Replies View Related

Android :: SingleTask Really Always At Root Of Activity Stack?

Sep 16, 2009

In the documentation it is stated that an activity with launchMode="singleTask" is always at the root of the sctivity stack. However, when I run my "singleTask" activity for a few scenarios and monitors behaviour with "adb shell dumpsys activity" I can see it placed both at the top of the stack (with numActivities=2) and in the middle of the stack (with numActivities=3). The activity at the root (frontOfTask=True) has a "normal" launchMode.Is the documentation incorrect or am I missing something?

View 5 Replies View Related

Android :: Hack Activity Stack Of Your Application?

Dec 28, 2009

Differently from most application, the state of my application is not controlled by its stack of activities but by the state of a background service.

Here is my problem. Suppose I have a task running with a non empty stack of activities. The top activity is paused on background and not visible.Then for some reason the process that host both the service and top activity is killed. When I somehow return to my app application ( by pressing back key, resuming from recent apps menu),the framework launches the application again with the activity that was on the top of the activity stack before process got killed.

Okay, you would say that it is the expected behavior. But because my service is no longer alive , the top activity is no longer valid ( as the other activities which remain on stack) . I would like to clear the whole activity stack and launch another activity to explain the current situation to user.

I could put the follow code on every activity "if(not valid state) finish() and launch a new activity with clear top flag enabled " but I don't think it is clever. Is there a better way to control which activity will be launched after application is killed ?

View 4 Replies View Related

Android :: How Do I Return To Calling Activity If User Presses Back?

Aug 4, 2010

My MAIN activity is spawning a child activity that contains a ListView. While this ListView is being populated (through an AsyncTask), an indeterminate progress bar is shown.However, assuming that I am an impatient user and I press the BACK button, the progress bar is cancelled but I am left with a blank screen. I have to press BACK one more time to go back to the MAIN activity.I would like the app to go back directly to the MAIN activity by pressing BACK only once. Can somebody point me in the right direction? I am thinking I should call finish() somewhere but I don't know where to put it.

View 3 Replies View Related

Android : Make An Activity Destory When User Presses 'Back Button?

Sep 27, 2009

When I currently have my activity on the font of the screen, how can I make Android to 'destory' my activity when user clicks 'back' button? (i.e. onDestory of my Activity gets called)?

View 4 Replies View Related

Android :: Prevent Activity From Saving State When User Selects Back Button

May 2, 2010

I have an Activity with a list that is bound to a ListAdapter reading data into a ArrayList from a database. All is well when the data is first loaded. While the Activity is open and the list is being displayed it is possible and likely that the data in the database will be updated by a service but the list does not reflect the changes because the ArrayList does not know about the changes. If the Activity is no longer in the foreground as would be the case if the user goes to the home screen and then is brought back to the foreground I would like for the Activity to not display what it did prior but rather reload the data using the ListAdapter the view is bound to. I think something needs to call finish() but I am not sure what.

This is what I have in the Activity.

CODE:.......................

View 1 Replies View Related

Android :: How Do I Clear All Activities From Stack?

Jul 8, 2010

I am having trouble popping all activities off the stack using ntent.FLAG_ACTIVITY_CLEAR_TOP and android:launchMode="singleInstance". In my application activity A, launches activity B (via startActivity) which in turn launches activity C (via startActivity). On activity C the user presses a menu item to return to activity A. When they arrive at activity A, I want only A on the stack such that if they click the back button they return to the home screen (desktop). This is the code that I am currently using when the user presses a button to return to A: Intent i = new Intent(this, A.class); i.addFlags(Intent.FLAG_ ACTIVITY_ CLEAR_TOP); startActivity(i); All activities are defined as android:launchMode ="single Instance" in the project manifest. My code doesn't seem to work though. Once I'm back on activity A if I click the back button I return to activity C. Am I misunderstanding how to use Intent.FLAG_ACTIVITY_CLEAR_TOP?

View 2 Replies View Related

Android :: Stack Of Activity From Activity Stack

Nov 2, 2009

There is a stack of activity i want to call the activity from that stack , My question is that is it possible to check from that stack and call that intent.When i press home button and again when i press the executable it should start the activity where i have left .Is it possible?Any example related to the same would be great help

View 3 Replies View Related

Android :: How To Clear Current Activities In Stack?

Jul 26, 2010

Support App starts activity A, then A starts activity B and finishes itself. After that activity B starts activity C. Now the stack contains B and C, with C at the top. Then I click a button in activity C, and want it to clear B and C and start activity A, i.e. I want activity A to be the only activity in the stack. How can I make it?Edit: I made a test to use FLAG_ACTIVITY_CLEAR_TOP. But it didn't work in my case, because activity A is not running when button in activity C is clicked.

View 1 Replies View Related

Android :: Application Crashes When User Presses Back Button / Where To Put Code?

Oct 6, 2010

First of all, maybe i went about this the wrong way in the first place. Situation is, i have a listview that when an item is clicked, it creates an intent and calls startActivityForResult() to another activity, to be able to edit the entries in the row. and that other activity after editing the required values, returns back to the calling activity, when the user clicks on a save button. The activity then uses the row Id to update the item.My problem now is that, if the user presses the BACK button instead, the application crashes. i have been looking around and see solutions like using Shared Preferences or onSavedInstanceState(), but i don't know where exactly i should be putting the code?

View 1 Replies View Related

Android :: Finish Any Previous Activity In Stack From Current Activity?

Apr 27, 2010

How to finish any previous activity in application stack (at any level , I mean not immediate parent) , from current activity like on some particular event I want to invalidate this previous activity?

View 1 Replies View Related

Android :: Retain Only One Copy Of An Activity On Stack When Called From Non Activity

Jul 26, 2010

How can I make sure I only retain one copy of an activity on the stack when called from non-activity? When called from an activity I can just add the FLAG_ACTIVITY_REORDER_TO_FRONT flag to the Intent, but how can I do this from e.g. a widget or a notification?

View 1 Replies View Related

Android :: Strange Activity Stack Behavior When Using Map Activity

Apr 23, 2010

I have the following activity structure in my application A simple "splash screen" activity is started when the application is fired up (let's call it "Splash"). This activity starts the main activity when the user presses a button (I will call it "Main"). Main can in turn start two activities from the menu. The first activity presents a simple form (let's call this one "Form"), the second is a MapActivity that presents a map (it is called "Map").
Main, Form, and Map are declared exactly the same in the manifest:
<activity android:name="fully qualified activity class"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|orientation"
> <intent-filter>
<action android:name="android.intent.action.DEFAULT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter> </activity> When Main is active and I start Form and press "back", Main comes up again. Pressing "back" again brings up "Splash". Nothing strange here.Now comes the strange part: when I am in Main, start Map, and press "back", Main comes up as expected. But pressing "back" again just restarts Main. A second press on "back" is needed to bring me back to Splash!So it seems that starting the Map activity somehow results in Main ending up on the activity stack twice while starting the Form activity does not! Both Form and Map are started like this: start Activity(new Intent(this, MyActivity.class)); I don not catch the back key in any activity.Any clues on what is going on or how to debug this?

View 1 Replies View Related

Android :: Closing More Than One Activity In Activity Stack

Nov 4, 2009

I'm new android and i want to know how to remove more than one activity from stack. We use finish() for closing particular activity but i wanna close more than one activity underneath it, at a time.

View 2 Replies View Related

Android :: Handle Existing Instance Root Activity Launching Root Activity From Intent Filter

Apr 3, 2010

I'm having difficulties handling multiple instances of my root (main) activity for my application. My app in question has an intent filter in place to launch my application when opening an email attatchment from the "Email" app. My problem is if I launch my application first through the the android applications screen and then launch my application via opening the Email attachment it creates two instances of my root activity. steps: Launch root activity A, press home Open email attachment, intent filter triggers launches root activity A Is it possible when opening the Email attachment that when the OS tries to launch my application it detects there is already an instance of it running and use that or remove/clear that instance?

View 1 Replies View Related

HTC Desire :: Every Installed And Uninstalled Application Leaves Some Files That Fills Up This 150mb?

Jul 16, 2010

As you may all know Desire has nearly 150mb internal memory for applications so I'm doing my best to use it wisely,

My problem occured when I start to install and uninstall many applications just for testing. I've seen that every installed and uninstalled application leaves some files that fills up this 150mb.

At my phone I had, CoPilot live + Several games + Google Earth. Now I've none and but when I try to install CoPilot or Google Earth I'm facing the fact that there is no space left.

I think applications might be leaving installer file behind when applications installed through HTC Sync, this might be the only logical reason.

View 3 Replies View Related

Android :: Start Activity And Clear Activity History

Apr 22, 2010

I have a huge maze of activities in my application. What I need to do, is that when the user logs in into the system, the activity history should be cleared. I cant just use finish() when I start a new activity, because I want the activities to have a history until the user logs in. I have experimentet with the different flags when starting an activity, but I have had no success.

View 1 Replies View Related

Android :: Way To Tell When Task Goes To Back Of Stack?

Mar 23, 2009

Is there a way to tell when my task gets put on the back of the UI stack (user pressed "home" say?) I have some resources I'd like to free when not foregrounded. The lifecycle routines seem dicey to use to try and infer this. The "home" key does not seem to be passed to onKeyDown(), and moveTaskToBack() is never called by the system so I can hook it. I can poll the ActivityManager for running activities with my task id, but hard to find a good time to call this.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved