如何解决Android 5.0中出现的警告:Service Intent must be explicit
来源:互联网 发布:转运物品 淘宝 编辑:程序博客网 时间:2024/05/22 06:18
有些时候我们使用Service的时需要采用隐私启动的方式,但是Android 5.0一出来后,其中有个特性就是Service Intent must be explitict,也就是说从Lollipop开始,service服务必须采用显示方式启动。
而android源码是这样写的(源码位置:sdk/sources/android-21/android/app/ContextImpl.java):
既然,源码里是这样写的,那么这里有两种解决方法:
1、设置Action和packageName:
参考代码如下:
此方式是google官方推荐使用的解决方法。
在此附上地址供大家参考:http://developer.android.com/goo ... tml#billing-service,有兴趣的可以去看看。
2、将隐式启动转换为显示启动:--参考地址:http://stackoverflow.com/a/26318757/1446466
调用方式如下:
而android源码是这样写的(源码位置:sdk/sources/android-21/android/app/ContextImpl.java):
既然,源码里是这样写的,那么这里有两种解决方法:
1、设置Action和packageName:
参考代码如下:
此方式是google官方推荐使用的解决方法。
在此附上地址供大家参考:http://developer.android.com/goo ... tml#billing-service,有兴趣的可以去看看。
2、将隐式启动转换为显示启动:--参考地址:http://stackoverflow.com/a/26318757/1446466
调用方式如下:
阅读全文
0 0
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- 如何解决Android 5.0中出现的警告: Service Intent must be explicit:
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- 我的Android进阶之旅------>如何解决Android 5.0中出现的警告: Service Intent must be explicit:
- 解决Android 5.0中出现的警告:Service Intent must be explicit
- 解决Android 5.0中出现的警告:Service Intent must be explicit
- Service组件 Android 5.0中出现的警告:Service Intent must be explicit
- 如何解决Android 5.0中出现的警告:Service Intent must be explict
- Service Intent must be explicit(Android 5.0中出现的警告)
- 解决Android 5.0中出现的错误:Service Intent must be explicit
- 日志库EasyLogging++学习系列(5)—— 辅助配置功能
- jQuery高级事件---on、off、one和事件委托
- 这里没有“软文黑稿”,给你看纯正独立的分享文章
- Thinkphp3.2.3登录页面验证码非正常显示
- C/C++种字符串的安全操作方式strcpy_s等字符串处理函数
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
- VirtualBox 配置虚拟网卡(桥接),实现主机-虚拟机网络互通
- xml数据解析
- Docker相关文章索引(3)
- TortoiseGit学习笔记(三)
- jQuery动画---显示、卷动、淡入淡出
- ARC forbids explicit message sendof'dealloc'
- var let 和const
- NGUI文字闪烁效果