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:
 http://developer.android.com/guide/topics/fundamentals.html #actlife
Read the part about the Activity lifecycle. That should answer your
questions.

Kind regards,

Peter


2010/3/31 DroidBy <meikeng....@gmail.com>

>


Sponsored Links


Proper way to finish an activity

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


 Peter,

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.

Thanks.





> > >



Other Threads

1. Not able to add account on email client of emulator(sdk r2)

Hello everybody,
I am trying to add account(gmail) on EMail client of emulator(sdk r2),
It is not getting connected

I activated pop3 and Imap setting options from my gmail account.

and did the following settings in emulator

Incoming settings
    IMAP server: imap.gmail.com
    Port: 993
    Security type: SSL (always)
the out going setting  window screen is not coming .

I tried for pop3 also
POP sever   : pop.gmail.com
                    port: 995
                     Security type: SSL (always)

Whats the matter here, will anybody guide me.

Thank you
--~--~---------~--~----~------------~-------~--~----~

2. Data corruption in Binary SMS

Hi,

I am trying to send binary SMS. I am using android SDK 1.0_r2.  My
application is able to receive the SMS, but data I am receiving is
completely change from whatever I am sending.
Please help me in this regard.

My Code looks like
================================================
Sender
*byte[] data="Google".getBytes();*
smsManager.sendDataMessage(sendTo,scAddr,dstPort,data,sentPI,deliverPI);

===============================================================
Receiver
*public* *class* smsReceiver *extends* BroadcastReceiver {

*private* *static* *final* String *SMS_RECEIVED* =
"android.provider.Telephony.SMS_RECEIVED";

*public* *void* onReceive(Context context, Intent intent) {

*if* (intent.getAction().equals(*SMS_RECEIVED*)) {

Bundle bundle = intent.getExtras();

Object messages[] = (Object[]) bundle.get("pdus");

SmsMessage smsMessage[] = *new* SmsMessage[messages.length];

*for* (*int* n = 0; n < messages.length; n++) {

smsMessage[n] = SmsMessage.*createFromPdu*((*byte*[]) messages[n]);

}

*String str = new** String(smsMessage[0].getUserData());*

Toast toast = Toast.*makeText*(context, "Title: "+ str,Toast.*LENGTH_LONG*);

}
=========================================================================
When I checked with the help of de{*filter*}, I am receiving "
4F b, b,  " instead of "Google".

Thanks,
Mahantesh

--~--~---------~--~----~------------~-------~--~----~

3. Android query

4. Can I register a few developer accounts with the same credit card?

5. How to manage several screens

6. upgrade issues and other market problems for developers

7. Taking Screen Shots