views:

37

answers:

1

In most Android apps, when you press the Home button to "minimize" the application and then open the application again, you will be taken to the screen you were last on in that Application.

I've read the following:

When launched via icon on the home screen, Android will always start the activity with the android.intent.action.MAIN filter in your AndroidManifest.xml, unless the application is already running (in which case it will obviously restore the activity on top of the stack).

but this is not happening. When I launch the application a second time, it takes me to the main Activity. The application isn't being terminated. If I then navigate to the screen I was last on, all the data and such is there.

How do I make it do what I want? The related questions all seem to pose the same answer (the one I quoted above), but this is not holding true.

A: 

Are your activities in the same task? That is, are you starting any of your activities as FLAG_ACTIVITY_NEW_TASK? I'm not positive, but that could change on the resume behavior works.

Falmarri
Intent intentLaunchInbox = new Intent(ActivityLogin.this, ActivityInbox.class);startActivity(intentLaunchInbox);I start new Activities like this. I believe that uses FLAG_ACTIVITY_NEW_TASK by default?
Andrew
"Whether the instance can have other activities in its task. A "singleInstance" activity stands alone as the only activity in its task. If it starts another activity, that activity will be launched into a different task regardless of its launch mode — as if FLAG_ACTIVITY_NEW_TASK was in the intent. In all other respects, the "singleInstance" mode is identical to "singleTask"." I am using singleInstance. What can I do here?
Andrew
Is single instance required for your application to work correctly? My guess would be this is the problem. Try making it `standard` and seeing if it does what you expect. If in fact calling it as `singleTask` is what's causing it not to return to the correct activity, I'm not sure what can be done. I've never come across this problem myself but I'm sure there's a solution
Falmarri
I switched from singleInstance to singleTask and it seems to be working as I want it to. I only want a single instance of an Activity to be on the Activity stack.
Andrew