我有一个服务,请求另一个类,启动一个的AsyncTask如何在AsyncTask完成后停止服务?
服务 - >天气讲座>执行方法 - > Asynctask->由
new Weather(this).execute(); // the execute is a method of the class, not of the AsyncTask
执行
这是在服务推出
我该如何在服务中检测到AsyncTask已完成,因此我可以调用stopSelf?
我有一个服务,请求另一个类,启动一个的AsyncTask如何在AsyncTask完成后停止服务?
服务 - >天气讲座>执行方法 - > Asynctask->由
new Weather(this).execute(); // the execute is a method of the class, not of the AsyncTask
执行
这是在服务推出
我该如何在服务中检测到AsyncTask已完成,因此我可以调用stopSelf?
我们的应用程序目前采用的方法是注册一个BroadcastReceiver
对android.app.Service
这是设立监听从产生的基础AsyncTask#onPostExecute
发射的广播事件。这在我们的场景中是有利的,因为我们的服务产生了三个AsyncTasks,并且当所有三个AsyncTasks都完成时,我们想停止父服务,即我们的服务级别BroadcastReceiver
有三个匹配。
想我会在这里添加此之后,我偶然发现了这个问题时,回答了很久以后,但希望它可以帮助别人......
我没有一个完整的答案,因此只是一个评论。您不能在您的服务中使用IBinder,并在您的AsyncTask的onPostExecute()中发送消息。 http://developer.android.com/reference/android/app/Service.html#LocalServiceSample – 2010-06-26 16:40:32
我的服务没有使用IBinder的东西。 – Pentium10 2010-06-26 17:17:45