2

In android app, if specify in the manifest <Aftapplication> with a class decedent from the Application, this class will be instantiated and its onCreate() will be called when start the app. And the default activity specified in the manifest will be created as well.

After the app is stared and when long press on device's home button to show the 'recent activity' list, and from there swipe out the app.

Noticed the activity onDestroyed in called, and immediately the application class's onCreate() is called again. But the activity's onCreate() is not called until you click on the app icon in the luncher.

Question: why the application class's onCreate() is called at the time the activity is destroyed, instead to be called at when clicking on the luncher icon of the app?

Thanks!

lannyf
  • 9,865
  • 12
  • 70
  • 152
  • Swiping an activity from recent activities list does not usually kill the whole application. Didn't the application crash? Android automatically restarts crashed applications. Also, you would probably find who started the application in LogCat. – StenSoft Apr 02 '15 at 21:33
  • no crash. everything is normal. can't see who creates the application object when swipe off the app. it is understandable the activity could be destroyed but why the application object onCreate() is called at then? – lannyf Apr 03 '15 at 00:29

0 Answers0