On Tue, Aug 9, 2011 at 7:56 AM, kypriakos <demet...@ece.neu.edu> wrote:

> I am running a servlet on the phone that starts an Intent on an
> Activity class.
> The class starts the camera preview and takes a picture. Then I have a
> subsequent
> Intent start on the same Activity class to stop the preview. The
> second Intent
> will fall into the OnNewIntent. It also carries a set of extra
> parameters
> that I want to read and use iwthin the OnNewIntent. How do I access
> those
> Extra params? I have used Extra bundles before and I know how they
> work.
> So what do you mean I need to remember the Intent?
>

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

Reply via email to