0

There are two activities in my example, MainActiviy and EmptyActivity. In the MainActiviy, it create a notification, which target is the EmptyActivity. Well, EmptyActivity is very simple, just finish itself in its onCreate.

i added the trace in the MainActiviy's onDestroy and onBackPressed I have invoked the finish() method in the onBackPress

The problem is:

  1. open the application, and press back key, the log is printed in the logcat, means the MainActiviy's onDestroyed is invoked.

  2. if open the application, and press the notification from the status bar, and then press back key, then no log in the onDestroy is printed

  3. Strangely, if reopen the application, then the log in the onDestroy is printed..

Has anyone known why this happened. Thanks

i uploaded the example to the google drive

Test

mianlaoshu
  • 2,342
  • 3
  • 27
  • 48
  • http://stackoverflow.com/questions/4449955/activity-ondestroy-never-called – Shayan Pourvatan Jun 18 '14 at 08:13
  • Did you find something ? I think I have quite a similar issue here : http://stackoverflow.com/questions/29941929/why-ondestroy-inactivity-a-not-being-called-after-a-call-to-finish-in-activity?noredirect=1#comment48007048_29941929 – gleroyDroid Apr 29 '15 at 12:24

1 Answers1

2

why minus my question!!! The link is different from mine !!

onDestroy() is called only when system is low on resources(memory, cpu time and so on) and makes a decision to kill your activity/application or when somebody calls finish() on your activity.

i have invoked finish() method!! My question is "why onDestroy() is not invoked after finish()"

Community
  • 1
  • 1
mianlaoshu
  • 2,342
  • 3
  • 27
  • 48