Proper way to finish an activity

by DroidBy » Wed, 31 Mar 2010 16:10:30 GMT

Sponsored Links
 I think someone here can anwer me..

I have an application with 3 activities, A, B and C.
Three points here:-
1. In normal user sequence, activity A will start activity B, activity
B will then start activity C.

2. In case, user is also allowed to cancel activity B (by a button),
and it will resume back to activity A.

3. If activity B is interrupted by any application which comes into
foreground, activity B should be killed and user should start from
activity A if user navigate back to my application.

In point 2, I have called finish() if user click on the button;

In point 3, I have called finish in activity B onPause() function

End up, I get an warning saying that I have duplicate finish request
by Activity Manager as in point 2, the onPause() will be called also.

So, does anyone here no how should I do in handling for point 2 so
that I am able to resume to activity A after user cancels activity B?
Or how should I do in case to stop my activity B so that user always
start from activity A?

Any best advise here?


Proper way to finish an activity

by Peter Fortuin » Wed, 31 Mar 2010 16:23:58 GMT

 Hi DroidBy,

Maybe it's a good idea to read the following: #actlife
Read the part about the Activity lifecycle. That should answer your

Kind regards,


2010/3/31 DroidBy <>


Sponsored Links

Proper way to finish an activity

by DroidBy » Thu, 01 Apr 2010 10:06:36 GMT


I read that before. But it still can't solve my problem in point 2.

As if I call finish during onPause(), then I will have duplicate
finish request complaint by the ActivityManager if user clicks on the
<Cancel> button which will call finish() , and then the activity will
enter into pause state and call finish() again.


> >

Proper way to finish an activity

by DroidBy » Thu, 01 Apr 2010 11:51:43 GMT

 Hi Peter,

Ya, by implementing some flags, I manage to see if I should call
finish in the onPause state.
Now my problem is resolved.


> > >

Other Threads

1. What could be the possible reason for this error?

We'd have to see some code to be able to help....

There are only 10 types of people in the world...
Those who know binary and those who don't.


2. Generic gestures

I'm developing a game that requires the user to input gestures for
common characters (mathematical operators and numeric characters,
mostly). I was wondering if there was a collection of generic
gestures, rather than creating a set using the gesture creator.

Thanks in advance

3. height of custom view

4. A possible bug??: global mode type-to-search not closing if the search is self directed with suggestions

5. what does this icon mean in Android Search Box

6. Trying to get Javascript on Android

7. battery life with proximity Alert