Distinguish Android onDestroy events -
i'll start saying i've seen activity lifecycle diagram (http://developer.android.com/reference/android/app/activity.html) , thouht understand perfectly.
how andestood if there ondestroy event, there no coming , activity in process of being shut down.
all others involve ability show activity again between oncreate , onstop (both inclusive).
i creating application polls custom bluetooth device measurements result. want connection (bluetooth) kept, want discover if user kills activity (from taskbar killing application) can send 1 more thing device , disconnect socket. understood, can put code in ondestroy. turned out (sony xperia z3 , samsung galaxy s2) ondestroy being executed when user clicks power button, locking screen. when screen unlocked, new activity (that guess) created , oncreate run. , can guess - device disconnected because of code put ondestroy
normal automatic screen off + lock not ondestroy...
so point is: there way distinguish ondestroy destroys activity, , ondestroy recreate same activity afterwards when user unlocks screen? want react really-really ondestroy event
yes there way distinguish ondestroy destroys activity:
@override protected void ondestroy() { super.ondestroy(); if (isfinishing()) { // bye-bye } else { // i'll } }
Comments
Post a Comment