我在服务中有这个代码。但调度程序没有启动!这有什么问题?即使应用程序在后台,我希望此服务每三秒显示一次祝酒...
public class notifService extends Service {
private final ScheduledExecutorService scheduler =Executors.newScheduledThreadPool(1);
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
final Intent intent1 = new Intent(this, notifService.class);
scheduler.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(),String.valueOf("a"), Toast.LENGTH_LONG).show();
}
}, 3, 3, SECONDS);
}
@Override
public void onDestroy() {
super.onDestroy();
}