2 messages in com.googlegroups.android-developersRe: bug in Context.startActivity(Inte...
FromSent OnAttachments
me28 Dec 2007 11:33 
hackbod29 Dec 2007 09:59 
Subject:Re: bug in Context.startActivity(Intent)?
From:hackbod (hack@gmail.com)
Date:12/29/2007 09:59:53 AM
List:com.googlegroups.android-developers

This is working as intended. The activity will receive a call to onNewIntent() with the intent being used to re-launch it, which it can do with as it wants.

That said, you should avoid calling startActivity() from an intent receiver, since this is very disruptive to the user. The better approach is to use the notification manager, which lets you easily update the information displayed for the notification and control what happens when the user next selects it. This is certainly the case for an intent receiver that is intercepting SMS messages -- you don't want to allow someone to spam the phone and cause your activity to continually be restarted on top of the what the user is doing.

http://code.google.com/android/toolbox/seamlessness.html http://code.google.com/android/reference/android/app/NotificationManager.html

On Dec 28, 11:33 am, me <mike@gmail.com> wrote:

I think I have discovered a bug in Context.startActivity(Intent). Can a Googler confirm this? Also, can anyone recommend a workaround, such that a paused activity can get information from an IntentReceiver?

--- the scenario: upon receiving an incoming (sms) message, insider IntentReceiver.onReceiveIntent(Context, Intent smsReceivedIntent), Context.startActivity(Intent launchActivityIntent) is called.

If the activity to be started has not yet been started, then Activity.getIntent() is launchActivityIntent. This is good because prior to calling Context.startActivity, launchActivityIntent can be stuffed with data via putExtras.

However, if the activity has already been started, and is simply paused, then Activity.getIntent() is *not* launchActivityIntent, and appears to be the intent with which Activity was originally created. This is bad because in this case, one cannot pass information from