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的更多相关文章

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

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

  2. 我的Android进阶之旅------>如何解决Android 5.0中出现的警告: Service Intent must be explicit:

    我的Android进阶之旅-->如何解决Android 5.0中出现的警告: java.lang.IllegalArgumentException: Service Intent must be ...

  3. 我的Android进阶之旅------>怎样解决Android 5.0中出现的警告: Service Intent must be explicit:

    我的Android进阶之旅-->怎样解决Android 5.0中出现的警告: java.lang.IllegalArgumentException: Service Intent must be ...

  4. Activity 怎么和 Service 绑定,怎么在 Activity 中启动自己对应的 Service?

    Activity 通过 bindService(Intent service, ServiceConnection conn, int flags)跟 Service 进行绑定,当绑定成功的时候 Se ...

  5. Android Service总结03 之被启动的服务 -- Started Service

    Android Service总结03 之被启动的服务 -- Started Service 版本 版本说明 发布时间 发布人 V1.0 添加了Service的介绍和示例 2013-03-17 Sky ...

  6. 没有启动 ASP.NET State service错误的解决方法

    具体错误如下: 异常详细信息: System.Web.HttpException: 无法向会话状态服务器发出会话状态请求.请确保已启动 ASP.NET State service,并且客户端和服务器端 ...

  7. IIS启动失败,启动Windows Process Activation Service时,出现错误13:数据无效 ;HTTP 错误 401.2 - Unauthorized 由于身份验证头无效,您无权查看此页

    因为修改过管理员账号的密码后重启服务器导致IIS无法启动,出现已下异常 1.解决:"启动Windows Process Activation Service时,出现错误13:数据无效&quo ...

  8. Android开发之通过Intent启动其他App的Service

    在Android5.0以前可以通过隐式Intent方式启动其他App的Service,就跟Activity启动隐式Intent一样的. 但是在5.0以后,只能使用显示的Intent方式启动了. 启动其 ...

  9. Windows Service 学习系列(二):C# windows服务:安装、卸载、启动和停止Windows Service几种方式

    一.通过InstallUtil.exe安装.卸载.启动.停止Windows Service 方法一 1.以管理员身份运行cmd 2.安装windows服务 切换cd C:\Windows\Micros ...

随机推荐

  1. jqgrid 合并表头

    参考:http://www.trirand.com/jqgridwiki/doku.php?id=wiki:groupingheadar jQuery("#表格id").jqGri ...

  2. python学习第二课——while循环

    #while循环基础语句 while 1==1: print('OK') #死循环 #如何阻止死循环 count=0 while count<10: print('第'+(str)(count) ...

  3. 关于AJAX跨域和原生AJAX CORS跨域解决

    项目需求要在别人的域名下调用自己的接口,因为浏览器的同源策略是不允许不同域名下之间的信息交换,那就意味着要跨域处理 参考博客 :https://blog.csdn.net/Ulricalin/arti ...

  4. java 学习地址

    数组 JAVA中数组排序小结 Java中ArrayList和LinkedList区别    在往里面插入数据时.LinkedList会比ArrayList快很多,因为前者仅仅做了一个类型的插入,而后者 ...

  5. 简单模拟IOC容器:为添加了@Autowired的属性赋值(初始值)

    创建@Autowired注解 package com.zzj.test; import java.lang.annotation.ElementType; import java.lang.annot ...

  6. 如果shell到win上出现乱码怎么办

    如果shell到win上出现这样的乱码怎么办? 如果出现了乱码,不慌一条命令搞定它!!! chcp 65001

  7. Prometheus Operator【转】

    前面我们介绍了 Kubernetes 的两种监控方案 Weave Scope 和 Heapster,它们主要的监控对象是 Node 和 Pod.这些数据对 Kubernetes 运维人员是必须的,但还 ...

  8. idea中跑mapreduce报错, PATH设置错误

    问题如题,报错: [root@node01 servers]# hadoop jar loginVisit.jar cn.itcast.loginVisit.step1.Step1Main19/07/ ...

  9. esxi 版本升级命令

    先把zip文件通过XShell或者WinSCP上传到esxi服务器上面去,然后执行以下命令,完成升级并重启就可以了.

  10. [Luogu][P2458] [SDOI2006]保安站岗

    题目链接 看起来似乎跟最小点覆盖有点像.但区别在于: 最小点覆盖要求所有边在其中,而本题要求所有点在其中. 即:一个点不选时,它的儿子不一定需要全选. 画图理解: 对于这样一幅图,本题中可以这样选择: ...