在Android 5.0采用隐式意图启动方式
Intent intent = new Intent();
intent.setAction("b.aidl.DownLoadService");
bindService(intent, conn, BIND_AUTO_CREATE);
产生了如下 截图所示的bug
bug说明:
有些时候我们使用Service的时需要采用隐式意图启动的方式,但是Android 5.0一出来后,其中有个特性就是Service Intent must be explitict,也就是说从Lollipop开始,service服务必须采用显式意图方式启动.
解决方案:
Intent intent = new Intent();
intent.setAction("b.aidl.DownLoadService");
intent.setPackage("lq.cn.twoapp"); //指定启动的是那个应用(lq.cn.twoapp)中的Action(b.aidl.DownLoadService)指向的服务组件
bindService(intent, conn, BIND_AUTO_CREATE);
本文介绍了解决Android 5.0中由于系统限制导致无法使用隐式Intent启动Service的问题。通过增加指定包名的步骤,实现了在Lollipop及以上版本中成功启动Service组件。
1251

被折叠的 条评论
为什么被折叠?



