How is an Intent Service Declared in the Android Manifest?

83,081

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

Solution 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

Share:
83,081
gtdevel
Author by

gtdevel

Getting my feet wet with android app development...

Updated on February 27, 2020

Comments

  • gtdevel
    gtdevel about 4 years

    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

  • gtdevel
    gtdevel over 12 years
    What does declaring an icon for it do? And what does the enabled tag mean?
  • hooked82
    hooked82 over 12 years
    Explanations can be found here: developer.android.com/guide/topics/manifest/…
  • Hiren Dabhi
    Hiren Dabhi over 10 years
    how to declare local service in manifest e.g. activity class name is "TestActivity" and "MyService" inside this class.
  • IgorGanapolsky
    IgorGanapolsky almost 8 years
    What's enabled for?
  • JFar
    JFar almost 8 years
    enabled, according to developer.android.com/guide/topics/manifest/…, is whether or not the service can be instantiated by the system — "true" if it can be, and "false" if not. The default value is "true".