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().
精彩评论