I solved a similar issue by broadcasting that my service is actually active 
and running and then if my activity is active it receives that broadcast and 
does what it needs to do. This way the Activity always "knows" when the 
service is active.

The onBind is not applicable to my situation as my Activity and Service are 
independent of each other. (Activity starts/stops Service but Service does 
not need Activity for anything else)

On Friday, July 22, 2011 6:57:42 AM UTC-4, Mark Murphy (a Commons Guy) 
wrote:
>
> On Fri, Jul 22, 2011 at 4:35 AM, Animesh Sinha <anime...@gmail.com> wrote:
> > You are right in saying that android requires developers to write an
> > event-driven code and that effort needs to be put for designing the
> > whole chain of events.
> >
> > But for the following case as shown below, I don't think one can get
> > rid of the NullPointerException thrown in onClick() method of
> > MyServiceClient; Unless instead of storing Service Interface globally,
> > one stores it locally.
>
> Developers disable UI widgets until they can be used.
>
> Hence, developers would have R.id.someBtn disabled until
> onServiceConnected() is called, at which point they would enable that
> widget and thereby allow the user to request actions that involve the
> service.
>
> -- 
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Warescription: Three Android Books, Plus Updates, One Low Price!
>
>

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