Sunday 15 May 2011

android - Calling finish() in onPause in child activity so that user refocuses into parent activity. Child activity gets recreated instead -



android - Calling finish() in onPause in child activity so that user refocuses into parent activity. Child activity gets recreated instead -

i create kid activity "b" activity "a". if user should leave app reason (most hitting home button), activity "b" end , app @ activity "a" 1 time user resumes.

if phone call finish() manually, activity b ends , returns activity a. behaviour happen when user leaves app.

i have tried phone call finish() in onpause(), onstop() , in onuserleavinghint() of activity b. in each case, appears work correctly, , can see mparent.finishfromchild(this); beingness called within activity b.

however, user switches app, oncreate() of activity b gets called , user ends in activity b.

how can ensure end in parent activity when phone call finish() within onstop() (or similar) handler?

update: appears issue related activity b beingness declared using singleinstance launch mode. removing feature seems have resolved issue. changing has introduced other issues have since managed fix.

the reason happening activity b set singleinstance launch mode. reason set (by developer) related reason had wished activity ended when app in background - ensure user not reach activity hitting on other activities subsequently dispatched activity b.

to resolve this. first ensured no activities created b. instead homecoming b , pass required intents on a. simplifying stack. (calling activity b startactivityforresult() 1 possible way of doing this.)

now, reason singleinstance causes issue arise in scenario, because activity b launched in seperate new task. when user attempts resume, re-enter single-activity task. rest of app running in seperate task. thing task can reasonably expected relaunch activity. when user presses back, thing can there close task (and hence appear exit app). expected behaviour occur user have had have selected other, first task (through long click of task list).

hopefully self-answer can help has encountered similar issue.

android android-activity

No comments:

Post a Comment