如何在Android Manifest中声明Intent服务?

时间:2011-08-22 08:39:20

标签: android service android-manifest intentservice

直截了当的提问:

在Android Manifest中将IntentService声明为常规服务,还是有其他方式?它试图搜索它,但我找不到答案。

以下是常规服务声明:

 <service
                android:name=".NameOfService">
 </service>

谢谢

2 个答案:

答案 0 :(得分:62)

在您的清单中,您使用android:name=".Communication"声明服务,这意味着您的服务类应位于com.exercise.AndroidClient.Communication

检查包裹是否正确。注意“。” (点)指的是包的根(即清单中声明的​​包)。因此,例如,如果您的软件包为com.exercise.AndroidClient且服务类位于com.exercise.AndroidClient.services.Communication下,则需要声明此服务:

<service android:enabled="true" android:name=".services.Communication" />

或指定完整的包裹:

<service android:enabled="true" android:name="com.exercise.AndroidClient.services.Communication" />

答案 1 :(得分:14)

与常规

没什么不同

这是我的

<service android:name=".MyIntentService" android:icon="@drawable/icon" android:label="@string/app_name" android:enabled="true"/>

如果你的工作不正常,请尝试

<service android:name="com.my.qualified.MyIntentService" android:icon="@drawable/icon" android:label="@string/app_name" android:enabled="true"/>

修改

当你去设置&gt;&gt;应用程序&gt;&gt;运行服务 将显示正在运行的服务列表。

android:icon 将是拇指图像

androin:label 将是显示文字