java.lang.IllegalArgumentException: Service Intent must be explicit
2016-03-29 17:23
555 查看
Android 5.0 手机上出现了崩溃:
AndroidRuntime:
java.lang.RuntimeException: Unable to start receiver com.yulore.recognize.android.receiver.PhoneStateReceiver: java.lang.IllegalArgumentException: Service Intent must be explicit
经查询,原因是Android 5.0对Service Intent的调用策略发生改变了,必须通过显示Intent来启动Service,详细介绍可以看stackoverflow上的介绍。
解决办法如下:
1、通过显示意图启动Service(直接用类名);
[java] view
plain copy
Intent intent = new Intent(com.yulore.test.AppService.class);
context.startService(intent);
2、如果想继续使用隐式意图的话,加上包名信息即可;
[java] view
plain copy
Intent intent = new Intent();
intent.setAction("com.yulore.recognize.android");
intent.setPackage(context.getPackageName()); //兼容Android 5.0
context.startService(intent);
查询自:http://blog.csdn.net/top_code/article/details/45719919
AndroidRuntime:
java.lang.RuntimeException: Unable to start receiver com.yulore.recognize.android.receiver.PhoneStateReceiver: java.lang.IllegalArgumentException: Service Intent must be explicit
经查询,原因是Android 5.0对Service Intent的调用策略发生改变了,必须通过显示Intent来启动Service,详细介绍可以看stackoverflow上的介绍。
解决办法如下:
1、通过显示意图启动Service(直接用类名);
[java] view
plain copy
Intent intent = new Intent(com.yulore.test.AppService.class);
context.startService(intent);
2、如果想继续使用隐式意图的话,加上包名信息即可;
[java] view
plain copy
Intent intent = new Intent();
intent.setAction("com.yulore.recognize.android");
intent.setPackage(context.getPackageName()); //兼容Android 5.0
context.startService(intent);
查询自:http://blog.csdn.net/top_code/article/details/45719919
相关文章推荐
- OC与c混编实现Java的String的hashcode()函数
- java中的异常
- Spring IOC三种注入方式(接口注入、setter注入、构造器注入)
- 【spring】spring session的一些细节
- java版 仿qq代码 完整源码 (已测试)
- file:${user.dir}:spring读取工程外的properties文件
- 我对java IO流简单的理解
- JAVA基础--数组
- SpringMVC基本配置
- eclipse远程提交scala到spark集群问题
- 了解RxJava之基础(一)
- springmvc学习笔记
- Java多线程——寺庙问题
- Spring mvc 配置事务的注意点
- java方法调用之单分派与多分派(二)
- [JAVA]学习笔记(三)——访问权限控制
- Spring注解
- JAVA内存模型(Java Memory Model)
- java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "javamelody jenkins
- Java 实现文章汉字关键词(违禁词)识别2.0