在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不行
新闻热点
疑难解答