Till - gotohuman.com
Till - gotohuman.com

Reputation: 6075

Is it possible to place a service in a subpackage?

My Service is only working if I have the MyService.java in a package like

com.test.app

, but NOT in a subpackage like

com.test.app.services.MyService

In the manifest I tried declaring it with

<service android:name=".services.MyService" />

or fully qualified

<service android:name="com.test.app.services.MyService" />

but neither way worked. I am using subpackages for a better structure of my files. So can I really not put my service file in a subpackage or am I missing something here?

(I am working with the Expansion Downloader Library provided by the Android team. This involves implementing a simple service.)

Upvotes: 3

Views: 458

Answers (2)

kabuko
kabuko

Reputation: 36302

Yes, you can put it in whatever namespace you want.

Beyond subclassing DownloaderService you need to read the rest of the document, including Starting the download. Of particular interest is this line:

// Start the download service (if required)
int startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(this,
                pendingIntent, SampleDownloaderService.class);

Note that you need to provide your custom Service class here.

Upvotes: 1

Argyle
Argyle

Reputation: 3394

Yes.

I've done this many times. Chances are there's something else going on. The first thing I'd check is to make sure your Intent is properly constructed.

Upvotes: 0

Related Questions