madmax wrote: > I have an Android Service that 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-are-not/ > 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 the service all the time to get that > event... The service itself 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 > service and activity. This is essentially the polling mechanism. Have the service send 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/commonsguy http://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 at http://groups.google.com/group/android-developers?hl=en