Another suggestion: each time the code shown is executed it is going to 
create a new instance of the handler. Is it truly executed as shown?

I use this with no problem but my code is more like...

Handler mHandler;

in onCreate()...
mHandler = new Handler();
mHandler.postDelayed(..)

in somewhereElse()...
mHandler.removeCallbacks(...)


On Tuesday, 3 July 2012 14:32:44 UTC+1, B.Arunkumar wrote:
>
> Hi, 
>
>    Thank you for your replies. The value of millisecs I am using is of 
> the order of 5000 millisecs. Actually, you may be right. There might 
> be cases where probably the removecallback executes in the secondary 
> thread faster than setting the handler postdelayed in the main thread. 
>
> Thank you, 
> B.Arunkumar 
>
> On Jul 3, 4:47 pm, skink <[email protected]> wrote: 
> > B.Arunkumar wrote: 
> > > Hi, 
> > 
> > >      Thank you for your reply. This is roughly the framework of code I 
> > > am using: 
> > 
> > > Main Thread :- 
> > 
> > > Handler handler = new Handler(); 
> > > handler.postDelayed (runnable,miilisecs); 
> > 
> > > Another Thread :- 
> > 
> > > handler.removeCallbacks(runnable) 
> > 
> > > But I find that handler.postDelayed (runnable,miilisecs) still 
> > > executes after handler.removeCallbacks(runnable) is executed in the 
> > > other thread. 
> > 
> > what do you mean by: 
> > "But I find that 
> > handler.postDelayed 
> > (runnable,miilisecs) still 
> > executes"? 
> > 
> > if you call postDelayed after removing runnable it is normal that your 
> > runnable will be run 
> > 
> > pskink

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