Friday 15 June 2012

android - finish() on an Activity closes app then briefly shows previous Application -



android - finish() on an Activity closes app then briefly shows previous Application -

in app, activity1 launches activity2 "startactivityforresult()".

when activity2 done, next code called:

activity2.java

private void finishactivity(final boolean accepted) { intent returnintent = new intent(); setresult(accepted ? result_ok : result_canceled, returnintent); finish(); }

activity1 receives callback, , if result not result_ok, finishes.

activity1.java

@override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (requestcode == globals.request_code_tos) { if (resultcode != result_ok) finish(); } }

after activity1 finishes app closes, expected.

the problem --

however, after app closes, instead of going home screen, previous application on stack briefly launches forward, closes also! home screen.

in android bug tracker, see similar bug listed case when button pressed, believe same calling finish():

https://code.google.com/p/android/issues/detail?id=71067

i'm seeing on nexus 5, running 4.4.4.

is bug? or there workarounds behavior?

edit --

to clarify behavior desire:

in google maps, if decline tos popup, app closes , go straight home screen. there no awkward flash opened app.

this decidedly same issue one linked in question (i've been next months, own nexus 5 myself). fixed in aosp, particular prepare doesn't seem have found way n5 yet. i've got fingers crossed prepare in lollipop, we'll see when rolls out.

as workaround, don't think exists @ moment, although if i'm wrong on love know - work on app myself similar (manually calls finish() bottom-most activity in stack when closed via button).

android android-activity activity-finish

No comments:

Post a Comment