Android - prevent recreating activity when returning from web browser -


in activity b have option "help" opens url in web browser. when returning web browser (with key) activity recreated. why happening , how prevent this?

edit: how call web browser:

intent browserintent = new intent(intent.action_view, uri.parse(getstring(r.string.help_url))); startactivity(browserintent); 

when returning browser oncreate() called;

my logical operations: when starting app, activity a reads settings , write activity/class c. after start activty b , finish() activity a. in activity b, oncreate() method reading settings activity c.

to must finish activity before starting browser.

change code to:

intent browserintent = new intent(intent.action_view, uri.parse(getstring(r.string.help_url))); finish(); // should called current activity startactivity(browserintent); 

android doesn't store information current activity when goes other (i.e. webbrowser), activity must recreated show again.

if still need activity after coming webbrowser there no way prevent android recreating it. should save need overriding onsaveinstancestate , recreate activity using savedinstancestate.

look @ activity lifecycle. when android need free memory others processes may kill app (which in background). there other possible paths activity running state doesn't recreate it. (onpause -> onresume , onstop -> onrestart -> onstart -> onresume)


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -