Service Intent must be explicit

来源:互联网 发布:网络游戏数据修改器 编辑:程序博客网 时间:2024/04/29 10:21

java.lang.IllegalArgumentException: Service Intent must be explicit: Intent

在Activity中启动Service的时候报错: 服务意图必须是显性声明。 这是为了防止造成冲突(有多个Service用同样的intent-filter的情况)

这是Android 5.0 (Lollipop) 之后的规定。 不能用包名的方式定义Service Intent, 而要用显性声明:

new Intent(Context, Service.class);

Intent intent = new Intent();intent.setAction("com.itheima74.remoteservice");mConn = new MyConn();bindService(intent,mConn,BIND_AUTO_CREATE);
remoteservice 类在清单文件配置了action,4.1手机能正常运行,7.1不行




0 0
原创粉丝点击