Issue
I have 3 Activities:Activity A,B and C Activity A is my login activity where user logs in to his account, Activity B is the dashboard and Activity C is has ListView
On Android Phone: When im on Activity C i press Home button on my phone it takes me to home screen of phone and than when i try to start the app again it takes me to Activity A instead of Activity C where i left initially.
On Emulator: When im on Activity C i press Home button on my phone and than when i try to start the app again it takes me to Activity C.
Also i have setup onResume on each activity just to check if phone has access to internet when the activity is resumed. Now the problem is that i don't understand why im not getting the same behavior on phone as im getting on emulator.
I want app to start from the Activity C where i left it.I want the same behavior as im getting on Emulator.
Also no errors or crash is happening on emulator.So its hard for me to track down the problem.
Please guide me on what should i do or please tell me what might be the problem.
Thank You!!
Solution
Concerning you are not using Eclipse to launch the app - I would like to introduce another solution.
Please take a look at the following key of Activity tag in Manifest: android:alwaysRetainTaskState
http://developer.android.com/guide/topics/manifest/activity-element.html#always
According to documentation, it's default value is false. If set to true in the task-root activity (Launcher in your case, I think) - it will tell the system to always keep the state of the task and do not reset it. So even when the process will be killed - after relaunch you should appear in the latest task state.
However, be careful, because this approach will be ruined if
- You will specify it not for root of the task.
- If you use Task-manipulating flags for your intents inside application. For example FLAG_ACTIVITY_CLEAR_TASK/FLAG_ACTIVITY_CLEAR_TOP/etc
Good luck
Answered By - AlexN
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.