How is an Intent Service Declared in the Android Manifest?

こ雲淡風輕ζ 提交于 2019-11-26 11:16:29

问题


Straight forward question:

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.

Here is the regular Service declaration:

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

Thanks


回答1:


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

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" />



回答2:


Nothing different same as a regular one

Here is mine

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

If yours is not working try something like

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

EDIT

When you go to settings >> application >> running services the list of running services will be displayed.

The android:icon will be thumb image

and androin:label will be the display text



来源:https://stackoverflow.com/questions/7144908/how-is-an-intent-service-declared-in-the-android-manifest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!