无法从AsyncTask的启动服务 [英] unable to start service from AsyncTask

查看:128
本文介绍了无法从AsyncTask的启动服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从启动服务的AsyncTask,但不能看到它的开始。我还添加了对服务文件manefast

I am trying to start service from AsyncTask but cant see that its starts. I also added Service on manefast file.

这里的code:

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>

感谢您的帮助。

推荐答案

services.conServise 应该在&lt;作用&GT; 中标记&LT;意向滤光器&gt; 为服务的声明标记,请更换的 servicesclassname 的例如与适当的包名, org.mypkg.foo.bar

services.conServise should be in a <action> tag within the <intent-filter> tag for that declaration of service, please replace servicesclassname with the appropriate package name for example, org.mypkg.foo.bar.

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

这篇关于无法从AsyncTask的启动服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆