0

I have created an activity , set it's filter as a Home activity and set launchMode with singleTask. When I press home ,the activity will be in onpause state then onStop . What confuse me is why the activity will be re-launched when back from icon displayed on "home pick" dialog ? It calls onCreate() again without invoked onDestroy().

I know there is a way to solve this problem that is to set launcherMode as singleIstance, but this way is not good enough, because it will cause an other issue that the activity will not be able to process onActivityResult.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • @Darpan ,i wish the activity will not to be killed by home bottom. I found that it happened only once after the app was just installed . – maozedong Nov 07 '14 at 08:03

1 Answers1

0

You may want to tell what you wish to achieve. Because that's how singleTask is. It delivers existing intent to onNewIntent() of the existing instance of activity. So activity will not be destroyed but onCreate() will be called, as it will reCreate activity with existing intent.

Quoting the documentation

The system creates the activity at the root of a new task and routes the intent to it. However, if an instance of the activity already exists, the system routes the intent to existing instance through a call to its onNewIntent() method, rather than creating a new one.

Darpan
  • 5,623
  • 3
  • 48
  • 80