On Thursday, July 21, 2011 1:26:54 AM UTC-4, Animesh Sinha wrote:

> The issue is that I need to call the service methods as soon as it is 
> connected. 
> So, Is there any way by which I can execute the functions of service 
> JUST AFTER binding is complete ? 
>
> It takes around 10-20ms for binding, I tried to make use 
> Thread.sleep(30); but it delayed the service from being connected by 
> the same sleep duration, therefore not solving the problem. 
>

The problem is that android requires you to write event driven code here.  
It can't deliver a new event until you return from the current event.  If 
you sleep, you just delay the return, and thus the new event delivery which 
can only occur after that.

You are going to have to do a lot of re-thinking of how to architect this 
whole process as a chain of events.  Yes, it's painful, but you'll get 
better at that kind of re-shuffling with time.

 

> On Jul 20, 6:33 pm, Mark Murphy <mmu...@commonsware.com> wrote: 
> > On Tue, Jul 19, 2011 at 12:21 PM, animeshsi <anime...@gmail.com> wrote: 
> > > Is there some way by which I can make sure that the service binding is 
> > > complete before any access is made to functions provided by the 
> > > service ? 
> > 
> > Don't try using the Binder until onServiceConnected() is called. 
> <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

Reply via email to