onDestroy() is not called on Android when cloased to make space

1,016 views
Skip to first unread message

Wilin

unread,
Feb 27, 2012, 9:26:53 AM2/27/12
to phonegap
When an application (in the background) is closed because Android
needs to make space for other (foreground) application normally
onDestroy is called wich in phonegap triggers the unload event. In my
phonegap programs (PG 1.4.1) The unload event is not called and after
adding

@Override
public void onDestroy() {
Log.i("BikeFlux", "onDestroy, before super");
super.onDestroy();
}

to my activity showed that onDestroy is only called when the
application is properly closed and not when it is closed when it is in
the background.

http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle
(info about Android lifecycle)

Is this because an error in Phonegap (DroidGap) or is it something
else?

greets

Wilin

Wilin

unread,
Feb 29, 2012, 6:05:14 AM2/29/12
to phonegap
Anyone with experience with this, or with the unloaded event?

Thanks

On Feb 27, 3:26 pm, Wilin <wim.ling...@gmail.com> wrote:
> When an application (in the background) is closed because Android
> needs to make space for other (foreground) application normallyonDestroyis called wich in phonegap triggers the unload event. In my
> phonegap programs (PG 1.4.1a The unload event is not called and after
> adding
>
>     @Override
>     public voidonDestroy() {
>         Log.i("BikeFlux", "onDestroy, before super");
>         super.onDestroy();
>     }
>
> to my activity showed thatonDestroyis only called when the
> application is properly closed and not when it is closed when it is in
> the background.
>
> http://developer.android.com/reference/android/app/Activity.html#Acti...

Bryce Curtis

unread,
Feb 29, 2012, 9:22:32 AM2/29/12
to phon...@googlegroups.com
If you look at the Android lifecycle chart you referenced, onDestroy may not be called if your app is killed.  If you need to persist data/state you should use onPause (which is the pause event).

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

Reply all
Reply to author
Forward
0 new messages