关于Android5.0当中的Service启动问题--- Service Intent must be explicit: Intent
来源:互联网 发布:小白管理器家庭网络 编辑:程序博客网 时间:2024/05/21 22:45
早上在调试程序的时候发生了这样的一个错误: Service Intent must be explicit: Intent
日志如下:
Unable to start receiver com.duk3r.eortologio2.MyStartupIntentReceiver: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.duk3r.eortologio2.MyService }好吧,现在来看代码:
Intent serviceIntent = new Intent(); serviceIntent.setAction("com.duk3r.eortologio2.MyService"); context.startService(serviceIntent);很简单的隐式启动Service操作,为何就出错了哪?
在官网发现了这样一个问题:
Binding to a Service
The Context.bindService()
method now requires an explicit Intent
, and throws an exception if given an implicit intent. To ensure your app is secure, use an explicit intent when starting or binding your Service
, and do not declare intent filters for the service.
解决方法也很简单,既然不让使用隐式启动,那就直接启动了,上代码:
Intent serviceIntent = new Intent(context,MyService.class);context.startService(serviceIntent);到此,问题解决,所以应该多去关注官方关于每个Android版本更新的描述!
参考链接:http://stackoverflow.com/questions/27842430/service-intent-must-be-explicit-intent
https://developer.android.com/about/versions/android-5.0-changes.html#BindService(需要科学上网)
0 0
- 关于Android5.0当中的Service启动问题--- Service Intent must be explicit: Intent
- 解决Android5.0及以上启动Service时,java.lang.IllegalArgumentException: Service Intent must be explicit
- service intent must be explicit:intent问题的解决
- Service Intent must be explicit
- Service Intent must be explicit
- Service Intent must be explicit
- Service Intent must be explicit的解决方法
- Service Intent must be explicit的解决方法
- Service Intent must be explicit的解决方法
- Service Intent must be explicit的解决方法
- Service Intent must be explicit的解决方法
- Service Intent must be explicit的解决方法
- Service Intent must be explicit的解决方案
- Service Intent must be explicit: Intent
- Service Intent must be explicit: Intent 解决
- 启动Service报错:Service Intent must be explicit
- Service异常:Service Intent must be explicit
- Android5.0 startService时崩溃 错误"Service Intent must be explicit"
- NotRxJava懒人专用指南-RxJava的演进过程
- springMVC命名空间
- PureMVC(AS3)剖析:设计模式(二)
- 电池电量的监测以及耗电操作时间点的分析
- Not a host:port pair: �
- 关于Android5.0当中的Service启动问题--- Service Intent must be explicit: Intent
- flash as3 timer 30秒后重新播放
- oracle执行计划中的cost,time与实际执行时间
- 在Ubuntu(Debian)上安装最新版Git
- 数学(hdu5212)
- 中国古人记录的奇妙客星
- ABAP字符串控制函数
- 怎样将PDF转成普通的Word文档格式
- Nature 自然