【发布时间】:2013-12-12 09:53:37
【问题描述】:
当我的 Activity 退出时,我在警报中注册了一个待处理的意图,它将在 60 秒内启动一个 NotificationService。 onCreate() 的代码如下:
PlayLogSender.getInstance(this).startSend();
和 startSend():
public void startSend(){
new Thread(){
@Override
public void run(){
log("[thread]started");
int interval=20;
try{
//wait for QTRadioService starting in case of this is a APP launch
Thread.sleep(interval*1000);
}catch(Exception e){}
log("sleep "+s+"s done");
while(some condition){
......
}
}
}.run()
}
当 PlayLogSender 的线程完成休眠后,android 杀死了 NotificationService;然后重新启动它并再次杀死它。最后 NotificationService 再也没有起床。我尝试将“间隔”设置为 15,然后一切正常。所以我认为android杀死它并不是因为内存。
有人可以帮忙吗?为什么 Android 会终止我的服务?
【问题讨论】: