Service must be explitict android 5.0问题

若是target到API 21,有一些注意的事项,如下是目前我发现的两个问题
1. Service must be explitict,从Lollipop开始,service必须显性声明,解决方案:
源代码参考
`sdk/sources/android-21/android/app/ContextImpl.java`html

 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 按钮文字默认大写,相关连接:,奇怪吧,看看源代码就知道java

    <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,。 在app中声明的explicit service,用电是在app头上,因此使用者看到的结果是android os 耗电不会很高,取而代之是各类app在耗电list裹。

4. Material Design Action Bar 默认是有shadow的,是由于新的elevation API, 因此你想去除它,要买在action bar style 的xml中,定义elevation 属性为0,要么android

 getActionBar().setElevation(0)
相关文章
相关标签/搜索