我的 Service仅当我在像
这样的包中有 MyService.java 时才有效com.test.app
,但不是像
这样的子包com.test.app.services.MyService
在 list 中我尝试声明它
<service android:name=".services.MyService" />
或完全合格
<service android:name="com.test.app.services.MyService" />
但两种方法都行不通。我正在使用子包来更好地组织我的文件。那么我真的不能将我的服务文件放在一个子包中还是我在这里遗漏了什么?
(我正在使用 Android 团队提供的 Expansion Downloader Library。这涉及实现一个简单的服务。)
最佳答案
是的,您可以将它放在您想要的任何命名空间中。
除了子类化 DownloaderService
之外,您还需要阅读文档的其余部分,包括 Starting the download .特别感兴趣的是这一行:
// Start the download service (if required)
int startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(this,
pendingIntent, SampleDownloaderService.class);
请注意,您需要在此处提供自定义的 Service
类。
关于android - 是否可以将服务放在子包中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10707674/