AIDL使用绑定启动远程Service出现Service Intent must be explicit: Intent
Intent intent = new Intent();
intent.setAction("remote.MyRemoteService.Action");
使用AIDL调用远程Service通过隐式意图的方式,但是出现了
Service Intent must be explicit: Intent { act=remote.MyRemoteService.Action }
抛出了一个异常,说意图不明确?
Android5.0以后绑定启动Service考虑到安全愿意,不允许隐式意图的方式启动,也就是说要给出一个明确的组件Service。intent.setPackage(String packageName)
或者intent.setComponent(ComponentName componentName)
都可以显示设置组件处理意图。那么下面这两种方式都能够解决:
Intent intent = new Intent();
intent.setAction("remote.MyRemoteService.Action");//Service过滤器的内容
intent.setPackage("cy.review.servicetest");//待使用远程Service所属应用的包名
Intent intent = new Intent();
intent.setAction("remote.MyRemoteService.Action");//Service过滤器的内容
//第一个参数待使用远程Service所属应用的包名,第二个参数所启动的远程Service完整类名
ComponentName componentName = new ComponentName(
"cy.review.servicetest",
"remote.MyRemoteService");
intent.setComponent(componentName);
参考:
https://blog.csdn.net/l2show/article/details/47421961
https://www.jianshu.com/p/52565022594e
AIDL使用绑定启动远程Service出现Service Intent must be explicit: Intent的更多相关文章
- java.lang.IllegalArgumentException: Service Intent must be explicit: Intent
在Activity中启动Service的时候报错: 服务意图必须是显性声明. 这是为了防止造成冲突(i.e. 有多个Service用同样的intent-filter的情况) 这是Android 5.0 ...
- 我的Android进阶之旅------>如何解决Android 5.0中出现的警告: Service Intent must be explicit:
我的Android进阶之旅-->如何解决Android 5.0中出现的警告: java.lang.IllegalArgumentException: Service Intent must be ...
- 我的Android进阶之旅------>怎样解决Android 5.0中出现的警告: Service Intent must be explicit:
我的Android进阶之旅-->怎样解决Android 5.0中出现的警告: java.lang.IllegalArgumentException: Service Intent must be ...
- Activity 怎么和 Service 绑定,怎么在 Activity 中启动自己对应的 Service?
Activity 通过 bindService(Intent service, ServiceConnection conn, int flags)跟 Service 进行绑定,当绑定成功的时候 Se ...
- Android Service总结03 之被启动的服务 -- Started Service
Android Service总结03 之被启动的服务 -- Started Service 版本 版本说明 发布时间 发布人 V1.0 添加了Service的介绍和示例 2013-03-17 Sky ...
- 没有启动 ASP.NET State service错误的解决方法
具体错误如下: 异常详细信息: System.Web.HttpException: 无法向会话状态服务器发出会话状态请求.请确保已启动 ASP.NET State service,并且客户端和服务器端 ...
- IIS启动失败,启动Windows Process Activation Service时,出现错误13:数据无效 ;HTTP 错误 401.2 - Unauthorized 由于身份验证头无效,您无权查看此页
因为修改过管理员账号的密码后重启服务器导致IIS无法启动,出现已下异常 1.解决:"启动Windows Process Activation Service时,出现错误13:数据无效&quo ...
- Android开发之通过Intent启动其他App的Service
在Android5.0以前可以通过隐式Intent方式启动其他App的Service,就跟Activity启动隐式Intent一样的. 但是在5.0以后,只能使用显示的Intent方式启动了. 启动其 ...
- Windows Service 学习系列(二):C# windows服务:安装、卸载、启动和停止Windows Service几种方式
一.通过InstallUtil.exe安装.卸载.启动.停止Windows Service 方法一 1.以管理员身份运行cmd 2.安装windows服务 切换cd C:\Windows\Micros ...
随机推荐
- 吴裕雄--天生自然HADOOP操作实验学习笔记:安装zookeeper集群
实验目的 了解zookeeper的概念和原理 学会安装zookeeper集群并验证 掌握zookeeper命令使用 实验原理 1.Zookeeper介绍 ZooKeeper是一个分布式的,开放源码的分 ...
- ubuntu用命令行打开vscode
1.打开终端 2.输入code即可
- bzoj 4487: [Jsoi2015]染色问题
先贴一个题解吧,最近懒得要死2333,可能是太弱的原因吧,总是扒题解,(甚至连题解都看不懂了),blog也没更新,GG http://blog.csdn.net/werkeytom_ftd/artic ...
- jquery使用css函数设置背景色无效解决办法
外部的css样式为: #imageArea{ width: 200px; height: 300px; background-color: #eee !important; } 通过 以下代码来修改其 ...
- 手把手教你如何在Presentation中拿高分
掐指一算,留学生们最近应该马上遇到Presentation作业.一般来说,这类的任务会占最终成绩的20-30%,对于期末成绩有一定的影响,如果想拿高分,就需要好好的准备.所以本文算是系列里的第一篇(扫 ...
- python表白实现代码(可视化与动画版)
python表白实现代码(可视化与动画版)如何优雅而又高大上地对自己的心爱女神表白了? ? ? 试试python表白的实现方式吧,是动画版的哦,保证可以如你所愿 ! ! !最终的实现效果如下: 具体实 ...
- 一、 SVN概述&工作方式&恢复历史版本
What why how 1 什么是SVN?作用是什么? SVN(SubVersion),版本控制系统.采用了分支管理系统,用于多人共同开发一个项目,共用资源的目的. 2 为什么要有SVN? 解决代码 ...
- poj 3069 Saruman's Army 贪心模拟
Saruman's Army Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18794 Accepted: 9222 D ...
- P1080 MOOC期终成绩
1080 MOOC期终成绩 (25分) 对于在中国大学MOOC(http://www.icourse163.org/ )学习“数据结构”课程的学生,想要获得一张合格证书,必须首先获得不少于200分 ...
- P1091 N-自守数
1091 N-自守数 (15分) 如果某个数 K 的平方乘以 N 以后,结果的末尾几位数等于 K,那么就称这个数为“N-自守数”.例如 3,而 2 的末尾两位正好是 9,所以 9 是一个 3-自守 ...