开发者

android question about service and the method onstartcommand

In a service 开发者_如何学Pythonclass there is a method to start the service. If that service gets done executing does it runs onstartcommand from the beginning? Is onstartcommand sorta like a loop as long as the service is running. For example i have

onStartCommand {
  int x = 0;
  if(x == 0){

  } else {
  }
}

After that is complete does it run it again. If you know that answer please explain. I have read google explanation of services and it did not explain that part very well. Is onstartcommand sorta like a loop as long as the service is runnning


No, it isn't. onstartcommand is run once. If you want to do something that takes long or does something recursively, you probably want to create a thread to do the hard job and just return from onStartCommand().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜