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)
最新文章
- 普林斯顿算法课第四周作业_8Puzzle
- ubuntu 搭建PPTP VPN服务器
- STL源码--序列式容器
- go 的 time ticker 设置定时器
- maven pom.xml解释 (转)
- POJ1298_The Hardest Problem Ever_最难的问题_Caesar 密码_C++
- (3)初次接触off
- wpf 绑定失效的原因及解决方案
- OpenSuSE zypper repo及Desktop媒体播放器设置 for OpenSuSE12.
- Linux学习netstat
- Get请求出现乱码的解决方案
- 我的Python成长之路---第二天---Python基础(8)---2016年1月9日(晴)
- oracle for update和for update nowait(for update wait)的区别
- Qt国际化相关类
- selenium+testN自动化测试框架搭建
- 根据自己的博客数据统计国内IT人群
- 针对Oracle的审计方案
- Future模式介绍及入门使用
- entity framework异常 The specified cast from a materialized &#39;System.Int32&#39; type to the &#39;System.String&#39; type is not valid
- day12-13 文件操作b模式