Hello Mark,

I have short question to your example :

If I understood it right, the Broadcast from the WeatherPlusService
will not start
up the WeatherPlus Activity ?

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.
I have the requirement, that when the devise status changed I have to
popup an alert dialog.

Must this really be done by the Service ?

Thanks  !

  Frank

On 3 Mai, 08:38, madmax <madmax.1...@gmail.com> wrote:
> Thanks a lot Mark! This is exactly what i was looking for.. It
> works..
>
>     Regards,
>       Prafull.
>
> On May 1, 6:25 pm, Mark Murphy <mmur...@commonsware.com> wrote:
>
>
>
>
>
> > madmaxwrote:
> > >              I have an AndroidServicethat runs indefinitely
>
> > That's not possible and is not a good idea in general:
>
> >http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-a...
>
> > > and
> > > wants to notify when a specific interesting event occurs to an
> > > activity. Now the problem is the "interesting event" occurs anytime
> > > and i don't want to "poll" to theserviceall the time to get that
> > > event... Theserviceitself should "notify" the activity about the
> > > event occuring. I looked around and came across a few methods to do
> > > it.
> > > 1) Using Intents and putExtras() : This method wont suffice for me
> > > because i "don't" want to start a new activity all  the time.
> > > 2) Using aidl : I already have an aidl for communication between the
> > >serviceand activity. This is essentially the polling mechanism.
>
> > Have theservicesend a broadcast Intent via sendBroadcast(), and have
> > the activity (when it is on-screen) dynamically register for that Intent
> > via registerReceiver().
>
> > Here is a sample project from one of my books that demonstrates the
> > technique:
>
> >http://github.com/commonsguy/cw-android/tree/master/Service/WeatherPlus/
>
> > --
> > Mark Murphy (a Commons 
> > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > Android Training...At Your Office:http://commonsware.com/training
>
> > --
> > 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 
> > athttp://groups.google.com/group/android-developers?hl=en
>
> --
> 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 
> athttp://groups.google.com/group/android-developers?hl=en- Zitierten Text 
> ausblenden -
>
> - Zitierten Text anzeigen -

-- 
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