I have a function::
public void doSleep() {
    handler.postDelayed(
        new Runnable() { 
      开发者_高级运维      public void run() { doCom(); } 
        }, 10000); 
}  
This is linked with doCom which starts this again. how can I finsh this at the end of the service?
you can also use
handler.removeCallbacks(Runnable r);
create a boolean flag in your class called sleep = true;
public void doSleep() {
    handler.postDelayed(
        new Runnable() { 
            public void run() { if(sleep) { doCom(); } } 
        }, 10000); 
}  
and set sleep = false; if you want to stop it.
use StopService() or StopSelf() methods where you want to stop
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论