You have legitimate points Dianne .. thanks for the detailed feedback. I am running a web server on the phone (iJetty) and the servlet that handles incoming requests starts an activity that puts the phone into a camera preview. This works fine. I wanted subsequent service calls to reach the same activity and stop the preview. Not sure if this is questionable or not to most but this is what I am after.
Let's take what I am after out of the equation. Is it possible to communicate with Activity B from Activity A using subsequent statements of Intent intent = new Intent() and set the Extras bundle? I do see the subsequent intent calls reach Activity B through the onNewIntent but the Extras are null. Someone pointed out that using FLAG_ACTIVITY_NEW_TASK is not the way to go - but if that's omitted and I only use FLAG_ACTIVITY_SINGLE_TOP then I get the exception: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag Thanks > What do you mean by servlet? Do you mean a Service? > > This design seems questionable to me. Trying to communicate with an > existing activity like this is fraught with peril -- what if the user > pressed home, you are popping yourself on top of whatever they are now > doing; what if they pressed back, you are launching a new instance; what if > they went down deeper in your activity stack, you are now doing ghod knows > what to the stack by pushing at it from the service. > > Generally if an activity wants to find out about state changes from a > service, it binds to the service and receives callbacks from it in any of a > number of ways -- through messengers, aidl, PendingIntent to deliver a > result, etc. > > Or if this is all one app running all one process, just have a singleton > that keeps track of the service and your activity can get it to see if it is > running and add a java interface callback for state changes. > > -- > Dianne Hackborn > Android framework engineer > hack...@android.com > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en