如何在一个Intent服务中声明的Android清单? [英] How is an Intent Service Declared in the Android Manifest?
问题描述
直截了当的问题:
在Android清单中声明为正规服务的IntentService,或有另一种方式?它试图寻找它,但我无法找到答案。
Is an IntentService declared in the Android Manifest as a regular service, or is there another way? It tried searching for it, but I couldn't find the answer.
下面是正规服务声明:
<service
android:name=".NameOfService">
</service>
感谢
推荐答案
在你的清单,你声明与 Android的服务:NAME =通讯
,这意味着服务类应该位于 com.exercise.AndroidClient.Communication
In your manifest you declare a service with android:name=".Communication"
, this means that your service class should be located in com.exercise.AndroidClient.Communication
检查包装是否正确。另外,。 (点),是指你的包的根目录下(即在清单中声明的包)。因此,举例来说,如果你的包是 com.exercise.AndroidClient
及服务类是在 com.exercise.AndroidClient.services.Communication
您需要声明的服务是这样的:
Check that the packages are correct. Note that the "." (dot) refers to the root of your package (ie the package declared in the manifest). So, for example, if your package is com.exercise.AndroidClient
and your service class is under com.exercise.AndroidClient.services.Communication
you need to declare the service like this:
<service android:enabled="true" android:name=".services.Communication" />
或指定完整包:
Or specify the full package:
<service android:enabled="true" android:name="com.exercise.AndroidClient.services.Communication" />
这篇关于如何在一个Intent服务中声明的Android清单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!