在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);