场景:现在写了两个应用AB:
A : 有一个Service:`com.test.MyService.class`
B :onClicke点击事件中调起A中的服务。
测试环境:魅族4,魅蓝3。
问题:
1)在A程序运行的情况下,B程序运行下,B点击去调起 MyService
服务,正常。
2)在A程序被杀死的情况下,即没有运行,B程序点击去调起服务,
不成功,没有任何的Log,Toast输出。
3)在A程序被杀死的情况下,即没有运行,用ADB命令去调起服务:
不成功,ADB输出,没有找到这个服务。
4)把这个程序A放在/system/app/下,让它成为一个系统的应用,
然后,在杀死程序的情况下,调起成功。
后续
公司的大神说,他能直接调起来,不用放在/system/app/下。
代码我查了好多次,我们两个的代码一样的。然后我注意到一点
我们的手机系统不同,他的是华为,我的是魅族。
有没有人跟我遇到一样的问题?求大神解释一下咯~
ringa_lee2017-04-18 09:15:36
It has been verified that Meizu system does not support the direct awakening of application layer services.
PHP中文网2017-04-18 09:15:36
I feel that it is best for your service to be independent in a new process: the service process. There is some mechanism for keeping the service alive or reconnecting. The simplest method is to let onStartCommand return the value START_REDELIVER_INTENT. If a Binder connection is established, Binder also has some reconnection mechanisms. For more ways to stay alive, read online articles, there are many
天蓬老师2017-04-18 09:15:36
I infer that it is an operation performed by the third-party system to prevent wake-up. It can be called natively, otherwise what is the use of the service?