20_ java.lang.IllegalArgumentException: Service Intent must be explicit异常说明

     在Android 5.0采用隐式意图启动方式

Intent intent = new Intent();
intent.setAction("b.aidl.DownLoadService");
bindService(intent, conn, BIND_AUTO_CREATE);

    产生了如下 截图所示的bug

   20_ java.lang.IllegalArgumentException: Service Intent must be explicit异常说明_第1张图片

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

 


你可能感兴趣的:(20_ java.lang.IllegalArgumentException: Service Intent must be explicit异常说明)