Android的另一个Android应用程式启动一个应用程序的服务 [英] Android start service of an app from another android app
问题描述
我已经安装在设备上的两个应用:从一个应用程序我想启动服务如下:
I have two applications installed on the device: from one app I want to start a service as follows:
Intent i = new Intent();
i.setComponent(new ComponentName("com.app.service", "com.app.service.NotificationService"));
context.startService(i);
第二个应用程序只能安装但尚未启动。
The second app is only installed but not started.
我要的是通过使用上述code,开始从第二个服务的通知服务(这应该创建一个通知)。
What I want is to start the notification service(which should create a notification) from the second service by using the above code.
在第二个应用程序的清单文件我宣布服务如下:
In the manifest file of the second app I declare the service as follows:
<service
android:name=".service.NotificationService"
android:exported="true" />
问题是,从第二个应用程序通知服务将无法启动。
The problem is that the Notification Service from the second app does not start.
这是为什么发生这种情况的任何想法?
Any ideas on why this happens?
推荐答案
不完全是一个很好的解决方案,但我已经通过从com.app.service目录NotificationService文件,并将其添加到com.app固定我的问题目录。
这个固定的问题,对我来说,这意味着我设法开始从第一个应用程序的第二个应用程序的服务。
Not exactly a great solution but I have fixed my problem by removing the NotificationService file from the com.app.service directory, and adding it to the com.app directory. This fixed the issue for me, meaning that I managed to start the service of the second application from the first application.
这篇关于Android的另一个Android应用程式启动一个应用程序的服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!