Tuesday, 15 February 2011

Android Backbutton Pressed Return to Two Activities -



Android Backbutton Pressed Return to Two Activities -

this may sounds simple, bewildered it. have searched not found solution.

my question is: how homecoming 2 activities when button pressed? this: allow me have activities a, b , c (a -> b -> c). want accomplish when on activity c , press button, should homecoming me activity a. when on b , press back, should homecoming me too.

it may implemented project many activities, assume don't need set class name of return, should recorded automatically android. how accomplish this?

thank you

a possible solution calling startactivityforresult() activity b, on callback of created activity c, previous activity b gets finished well. callback function called onactivityresult(), , in that, want phone call finish().

example:

activityb:

intent = new intent(this, activityc.class); startactivityforresult(i, 0); ... @override protected void onactivityresult(int requestcode, int resultcode, intent data) { this.finish(); }

activityc:

//do stuff

this way, when press (or phone call finish()) in activityc, phone call on activityb's onactivityresult() function, , end them both.

android

No comments:

Post a Comment