android : behaviour on pressing HOme key for single task

I have my first activity as single task . And the activities launched from this one are all the default launch mode. Now when i press HOME from any of these activities and then relaunch the application again by clicking the icon from the list of application, it is always the first activity that is getting launched. Ideally the activity from which HOME was pressed should regain the focus when brought to foreground. What is the logic behind this behavior assosiated with single task.


I'm assuming you mean intent rather than activity in some of your explanation. You'll need to read up on the OnPause() OnStop() and when Android calls them. When you press the Home button rather than the Back button, the application actually shuts down entirely. You need to save which intent you're currently in if you want it the application to jump right back where you left on. You'll want to put the logic for restoring your state in the start up code.

Handling Runtime Changes is what you'll want to look at. http://developer.android.com/guide/topics/resources/runtime-changes.html

链接地址: http://www.djcxy.com/p/26164.html

上一篇: Android:防止回到以前的活动

下一篇: android:按HOme键执行单个任务的行为