无法从开始的AsyncTask服务(unable to start service from Asy

2019-07-30 02:22发布

我试图从开始服务的AsyncTask,但不能看到它的开始。 我还添加了服务上manefast文件。

这里的代码:

protected Integer  doInBackground(Void... values) throws InterruptedException {
    //starts service number activite
    Intent serviceIntent = new Intent();
    serviceIntent.setAction("services.conServise");
    context.startService(serviceIntent);

和清单文件:

   <service android:name="services.conServise"></service>

  </application>

感谢帮助。

Answer 1:

services.conServise应该是在一个<action>的内标签<intent-filter>为服务该声明标记,请与例如相应的包名称,org.mypkg.foo.bar替换servicesclassname。

<service android:name="<servicesclassname>">
    <intent-filter>
        <action android:name="services.conServise"/>
    </intent-filter>
</service>


Answer 2:

经由的AsyncTask类onPostExecute()方法尝试。 谢谢



文章来源: unable to start service from AsyncTask