Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is an Intent Service Declared in the Android Manifest?

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

like image 589
gtdevel Avatar asked Aug 22 '11 08:08

gtdevel


People also ask

How do I declare a service in manifest Android?

You declare a service in your app's Manifest, by adding a <service> element as a child of your <application> element. There's a list of attributes that you can use to control a service's behavior, but as a minimum you'll need to provide the service's name (android:name) and a description (android:description).

How does intent service work in Android?

IntentService is a base class for Services that handle asynchronous requests (expressed as Intents) on demand. Clients send requests through startService(Intent) calls; the service is started as needed, handles each Intent, in turn, using a worker thread, and stops itself when it runs out of work.

What should service manifest declare?

Declaring a service in the manifest You must declare all services in your application's manifest file, just as you do for activities and other components. To declare your service, add a <service> element as a child of the <application> element.

What is declared in Android app manifest file?

The Android manifest file helps to declare the permissions that an app must have to access data from other apps. The Android manifest file also specifies the app's package name that helps the Android SDK while building the app.


1 Answers

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" /> 
like image 133
Randroid Avatar answered Sep 30 '22 06:09

Randroid