FrankG wrote:
> I have short question to your example :
> 
> If I understood it right, the Broadcast from the WeatherPlusService
> will not start
> up the WeatherPlus Activity ?

Correct. In this case, the WeatherPlus activity is already running.

> So how must the example be changed, that the first broadcast will
> startup the activity
> and the next ones are normal broadcast to send the new status to the
> activity.
> 
> I know that I can use startActivity( Intent ) to startup the
> activity ..and use then sendBroadcast(Intent),
> but you cannot know, whether then your Activity is still running.

Sure you can, though the sendBroadcast() model is probably not the right
one to use.

Have the activity bind to the service using the local binding pattern
and have it register a callback/listener object with the service once bound.

When the "devise status changed", the service looks to see if it has a
listener from an activity.

-- If yes, it calls a method on that listener to tell the activity to
display the dialog or whatever.

-- If no, the service starts the activity with an extra indicating "hey,
please go ahead and pop up that dialog, please"

Bear in mind that popping up an activity from a service is a very bad
practice except in unusual circumstances (alarm clock, incoming phone
call). If the user is in the middle of doing something else, and you
interrupt them forcibly, and they do not think your interruption is
warranted, they will get...cranky. :-)

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 2.0 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to