System kills my android app after some idle in onStop() state. How to avoid or detect this situation? -


i have application plays audio , video files remote server or own cache directory. when minimize application "home" or "back" button changes state onstop(). then, after idle (20-50 minutes or about) activity manager sends "no longer want" message activity , closes it.

according activity lifecycle in case aplication jumps oncreate (the branch left onstop() on diagram). when happens activity has incorrect representation - fragments track lists start load on top of existing ones, ui becomes unusable , way fix situation competely restart application.

i guess there 2 ways solve problem:

1) make system not kill application (may it's not correct, because approach violates normal application lifecycle in android , accelerates battery discharge).

2) detect situation when os kills application , clean resources let os create new activity properly.

i think second variant preferable.

is there ideas how implement it? possible detect android going kill application , react action?

thanks in advance!

  1. if app creates service nothing in idle state, not drain battery , pin process (you should put notification make claim stronger). whatever do, system may destroy app when low on resources. note callback guaranteed receive onpause(), , system upset if takes time complete. other calls - onstop() , finalizers - may skipped if system desperate.

  2. therefore, must also follow second strategy - imho simon's comment means - , handle onstart() , onrestart() correctly.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -