Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.)

like image 324
Till Avatar asked Jan 22 '26 13:01

Till


1 Answers

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.

like image 147
kabuko Avatar answered Jan 25 '26 03:01

kabuko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!