Service must be explitict android 5.0问题
如果target到API 21,有一些注意的事项,以下是目前我发现的两个问题
1. Service must be explitict,从Lollipop开始,service必须显性声明,解决方案:http://blog.android-develop.com/2014/10/android-l-api-21-javalangillegalargumen.html
源代码参考
`sdk/sources/android-21/android/app/ContextImpl.java`
private void validateServiceIntent(Intent service) {
if (service.getComponent() == null && service.getPackage() == null) {
if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP) {
IllegalArgumentException ex = new IllegalArgumentException(
"Service Intent must be explicit: " + service);
throw ex;
} else {
Log.w(TAG, "Implicit intents with startService are not safe: " + service
+ " " + Debug.getCallers(2, 3));
}
}
}
2. Material Design 按钮文字默认大写,相关链接:https://code.google.com/p/android-developer-preview/issues/detail?id=487,奇怪吧,看看源代码就知道
<style name="TextAppearance.Material.Button">
<item name="textSize">@dimen/text_size_button_material</item>
<item name="fontFamily">@string/font_family_button_material</item>
<item name="textAllCaps">true</item>
<item name="textColor">?attr/textColorPrimary</item>
</style>
3. 补充一点, 谢谢@King Sing提供。 JobScheduler 是可以通过System serviceContext.getSystemService(Context.JOB_SCHEDULER_SERVICE)来获得的,它不依赖于implicit service或者是explicit service,但explicit service是可以与JobScheduler交互,参考sample,https://github.com/googlesamples/-JobScheduler。 在app中声明的explicit service,用电是在app头上,所以使用者看到的结果是android os 耗电不会很高,取而代之是各种app在耗电list裹。
4. Material Design Action Bar 默认是有shadow的,是因为新的elevation API, 所以你想去除它,要买在action bar style 的xml中,定义elevation 属性为0,要么
getActionBar().setElevation(0)
Service must be explitict android 5.0问题的更多相关文章
- 《Thinking in Android 9.0 系统开发源码钻研录》
最近打算把个人站点的博客文章同步到"博客园"! Thinking in Android -- "系统启动" [启动阶段] [相关文章] 状态 源码版本 init ...
- 如何解决Android 5.0中出现的警告:Service Intent must be explicit
有些时候我们使用Service的时需要采用隐私启动的方式,但是Android 5.0一出来后,其中有个特性就是Service Intent must be explitict,也就是说从Lollip ...
- 解决Android 5.0中出现的警告:Service Intent must be explicit
extends:http://www.eoeandroid.com/thread-568853-1-1.html 本帖最后由 469874851 于 2015-3-11 18:15 编辑 有些时候我们 ...
- 我的Android进阶之旅------>如何解决Android 5.0中出现的警告: Service Intent must be explicit:
我的Android进阶之旅-->如何解决Android 5.0中出现的警告: java.lang.IllegalArgumentException: Service Intent must be ...
- 我的Android进阶之旅------>怎样解决Android 5.0中出现的警告: Service Intent must be explicit:
我的Android进阶之旅-->怎样解决Android 5.0中出现的警告: java.lang.IllegalArgumentException: Service Intent must be ...
- 如何解决Android 5.0以上出现的警告:Service Intent must be expli
有些时候我们使用Service的时需要采用隐私启动的方式,但是Android 5.0一出来后,其中有个特性就是Service Intent must be explitict,也就是说从Lollip ...
- [Android分享] 如何解决Android 5.0中出现的警告:Service Intent must be explicit
Android 5.0程序运行报Service Intent must be explicit错误,原因是5.0的service必须显式调用 改成 Intent intent = new Intent ...
- Android(4.0.3+): Service, AsyncTask, 定时任务和UI通信
Service使用AlarmManager实现后台定时任务 在Android 4.0.3版本中, 使用AlarmManager实现后台定时任务是比较好的方案, 其实现机制, 是利用Service的 o ...
- Android 8.0 启动后台service 出错 IllegalStateException: Not allowed to start service Intent
错误原因: Android 8.0 不再允许后台service直接通过startService方式去启动, 具体行为变更如下: 如果针对 Android 8.0 的应用尝试在不允许其创建后台服务的情况 ...
随机推荐
- 简述tcp三次握手
第一次握手:建立连接时,客户端向服务端发送SYN(同步序列编号),其中包含客户端的初始序号seq(序列号)=x,并进入SYN_SENT(请求连接)状态,等待服务器确认. 第二次握手:服务器收到请求后, ...
- Problem 1 珠江夜游 (cruise .cpp)———2019.10.6
Problem 1 珠江夜游 (cruise.cpp)[题目描述]小 Z 放假后难得来一趟广州游玩,当然要吃遍广州各路美食小吃然后再到珠江新城看看远近闻名的小蛮腰啦!可当小 Z 一路吃吃吃以后,天渐渐 ...
- SpringMVC效验器
效验器: 1. 效验器依赖 <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator --> &l ...
- 【转】Spring线程及线程池的使用
spring @Async 线程池使用 最近公司项目正逐渐从dubbo向springCloud转型,在本次新开发的需求中,全部使用springcloud进行,在使用时线程池,考虑使用spring封装的 ...
- (转载)如何在当前目录下快速打开cmd
很多时候我们需要打开命令行然后进入到相应目录进行一些操作. 常规的做法是: Win+R打开运行窗口 输入"cmd"回车打开命令行窗口 假如我们要进入的是D盘foo文件夹下的一个ba ...
- R包 survival 生存分析
https://cran.r-project.org/web/packages/survival/index.html
- OpenFOAM——冲击斜坡
本算例来自<ANSYS Fluid Dynamics Verification Manual>中的VMFL045: Oblique Shock Over an Inclined Ramp ...
- Unknown column 'startname' in 'field list
Unknown column 'startname' in 'field list 字段匹配不上 解决思路 1.检查数据库字段名与sql中的字段名是否一致 2.是否为关键字或中英文区别 ,(关键字可 ...
- 系统性能工具篇(sar)
转自:系统性能工具篇(sar) 1. 介绍 内容很多 是sysstat软件包的一部分 自动运行:/etc/crontab/sysstat $ cat /etc/cron.d/sysstat # The ...
- Java finally未被执行的情况
一种是先执行了用于终止程序的System.exit()方法,或进程被关闭 还有一种情况是,当前线程一直在执行,在一些业务逻辑里面跳不出来,看上去就像finally一直未被执行 线程被终止的时候也会执行 ...