我正在开发一款Android服务,该服务必须在后台运行,并每100秒执行一次函数。以下是源代码(示例):
package com.example
import ....
public class Servizio extends Service {
public IBinder onBind(Intent intent) {
}
public void onCreate() {
}
public void onDestroy() {
//here put the code that stop the timer cycle
}
public void onStart(Intent intent, int startid) {
//i want to begin here the timercycle that each 100 s call myCycle()
}
public void myCycle() {
//code that i can't move on other class!!!
}
}
我该怎么做?现在这个服务只会执行一次myCycle(),因为我把一个调用放在了onStart()里。