我试图理解逻辑的特定位IntentService
,具体而言,在ServiceHandler
:澄清IntentService
private final class ServiceHandler extends Handler {
public ServiceHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg) {
onHandleIntent((Intent)msg.obj);
stopSelf(msg.arg1);
}
}
从我可以告诉,stopSelf()
被称为多次 - 一次每拨打一次startService
。如果有多个项目要处理,stopSelf
是否不会中断待处理项目的流程?显然这不是发生了什么,因为IntentService
实际上工作,但为什么?看起来像stopSelf
应该在处理完所有Intent
之后调用。
另一个问题--创建的HandlerThread
何时会实际停止?显然它不会被stopSelf
阻止?
你并不需要调用'stopSelf'一个'IntentService'。更多信息在这里:http://stackoverflow.com/questions/10250745/proper-way-to-stop-intentservice –
事实上,因为'IntentService'确实实际的调用。我的问题是关于班级的内部运作。 – Melllvar