java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.gms.analytics.service.START (has extras) }

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

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

详细介绍可以看stackoverflow上的介绍。

解决办法如下:

1、通过显示意图启动Service(直接用类名);

  1. Intent intent = new Intent(com.yulore.test.AppService.class);
  2. context.startService(intent);

2、如果想继续使用隐式意图的话,加上包名信息即可;

  1. Intent intent = new Intent();
  2. intent.setAction("com.yulore.recognize.android");
  3. intent.setPackage(context.getPackageName());    //兼容Android 5.0
  4. context.startService(intent);

参考:

http://blog.csdn.net/shenzhonglaoxu/article/details/42675287

https://my.oschina.net/u/269663/blog/396826

http://blog.csdn.net/redarmy_chen/article/details/47832615

http://blog.csdn.net/ouyang_peng/article/details/50727693

http://blog.csdn.net/top_code/article/details/45719919

Service Intent must be explicit: Intent 解决相关推荐

  1. 【转】Service Intent must be explicit的解决方法

    [转]Service Intent must be explicit的解决方法 参考文章: (1)[转]Service Intent must be explicit的解决方法 (2)https:// ...

  2. Android中提示:Service Intent must be explicit:Intent

    场景 在使用bindService时第一个intent参数在声明时使用的 String actionName = "com.shoushuo.android.tts.intent.actio ...

  3. Explicit Intent Implicit Intent

    Intent用于启动Activity,Service或发送Broadcast.Intent的使用有隐式和显式之分,即Explicit Intent和Implicit Intent. Explicit ...

  4. 如何解决Android 5.0中出现的警告:Service Intent must be explicit

    从Lollipop开始,service服务必须采用显示方式启动. Intent intent = new Intent("a.b.c");intent.setPackage(get ...

  5. Service Intent must be explicit

    参考: http://blog.csdn.net/qs_csu/article/details/45114251 我做阿里云账号登录的时候,遇到一个问题,不知道阿里云服务的包名.怎么办?第二种方法可以 ...

  6. 显示Intent和隐式Intent

    转载自:https://www.cnblogs.com/liaojie970/p/5827433.html Intent是Android初学者比较难理解的一个东西.我这里以通俗易懂的语言和通俗易懂的代 ...

  7. 显式Intent与隐式Intent

    1.显式Intent(explicit intent) 显式Intent明确指定了要启动的activity: Intent intent= new Intent(this, Target.class) ...

  8. android intent email,Android Email Intent

    问题 I've set up two buttons. One opens the compose sms intent and the other opens the compose email i ...

  9. 2021-04-06 neo4j Service stop failed - service ‘neo4j’ not found 请问怎么解决?

    识别不到neo4j服务命令? 在win环境下配置安装好了neo4j社区版,版本号为3.5.5.安装完发现在黑屏终端下只认识neo4j console命令,stop,strat都报错! Service ...

最新文章

  1. 在Windows7/10上快速搭建深度学习框架Caffe开发环境
  2. HTML中将px转换为em的语法,在JavaScript中转换EM为PX(并获得默认字体大小)
  3. add多个文件 git 文件夹_利用 git 提取文件夹下多个特定文件里的内容写到特定文件内...
  4. linux下软件的安装[转]
  5. java 补充日期_Java 9对可选的补充
  6. C#开发终端式短信的原理和方法
  7. Chapter 3.GDI/DirectDraw Internal Data Structures
  8. 如何通过解决精益问题提高敏捷团队生产力
  9. igmpproxy_IGMP proxy开发笔记 | 学步园
  10. 6.Python学习笔记:[enumerate元素加序号;isdigit()像数字;len()计算长度]
  11. html文件是fla,FLASH 全屏、按ESC 退出全屏模式Fla及HTML源文件
  12. MATLAB实现追赶法
  13. word小技巧 将图片批量居中
  14. win10默认壁纸位置
  15. 系统没有安装任何软件如何查看电脑开机启动项
  16. 动态规划——最大连续子序列和
  17. 【Linux-GNU编译器套件(gcc/g++/gfortran)离线编译安装】
  18. 条件运算符与条件if的姻缘,打擂台算法和大小写字母转换,if逻辑避坑
  19. 【前端灵魂脚本语言JavaScript⑤】——JS中数组的使用
  20. 全网最简单的百度网盘提速方法!!!!

热门文章

  1. 第一章 统计学习方法概论
  2. Android autoLink的注意点
  3. 51单片机 蔬菜灌溉自动控制系统设计 程序 proteus 仿真 温湿度控制系统
  4. 同步四位二进制计数器逻辑图
  5. 蓝桥杯2013JavaA题7(错误票据)
  6. 淘宝商品价格计算实例
  7. 92. 递归实现指数型枚举
  8. 基于Halcon学习的缺陷检测【五】光伏电池片的指纹以及划痕检测【第二种方法】
  9. 【obs】wc:WindowsGraphicsCapture client-area BitBlt Compatibility
  10. 四通道数据采集卡(ADS6445、4 channel、14bit、125MHz)