欢迎访问移动开发之家(rcyd.net),关注移动开发教程。移动开发之家  移动开发问答|  每日更新

Android5.0和Android6.0适配,

来源: 开发者 投稿于  被查看 1363 次 评论:177

Android5.0和Android6.0适配,


gradle配置项

targetSdkVersion < 平台的API级别 向前兼容举个栗子:targetSdkVersion==23(6.0),当前设备Android版本7.0,运行程序时用6.0那一套接口。接口:API接口
targetSdkVersion = 平台的API级别 不启用兼容性
targetSdkVersion > 平台的API级别 举个栗子:targetSdkVersion==23(6.0),当前设备Android版本是 5.0 ,运行程序 用的是5.0那套接口。设备根本到不了6.0

是不是意味着targetSdkVersion越低越好?

minSdkVersion <= targetSdkVersion <= compileSdkVersion

andorid 5.0 新特性

android 5.0适配

  • android5.0 getRunningTasks 和getRunningAppProcesses(仅返回当前应用包名)失效
    解决方案
  • backgroundTint属性只能在5.0以上的api中调用
    解决方案
  • Android API 21(5.0)引入了一个Drawable的子类VectorDrawable
    解决方案(https://www.jianshu.com/p/0972a0d290e9)
  • Android5.0上 WebView中Http和Https混合问题
    解决方案

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
  • WebView cookie 存储问题

     public static void syncCookie(String url, String key) {
         CookieManager cookieManager = CookieManager.getInstance();
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             cookieManager.removeSessionCookies(null);
             cookieManager.flush();
         } else {
             cookieManager.removeSessionCookie();
             CookieSyncManager.getInstance().sync();
         }
         cookieManager.setAcceptCookie(true);
         cookieManager.setCookie(url, key);
     }
  • JobScheduler和JobService是安卓在api 21中增加的接口(保活),功能更强的闹钟


  • Android 6.0 适配及新特性

  • 取消支持 Apache HTTP
    解决方案:
    android {
    useLibrary 'org.apache.http.legacy'
    }

  • BoringSSL
    请勿链接到并非 NDK API 组成部分的加密库,如 libcrypto.so 和 libssl.so

  • 硬件标识符访问权
  • AudioManager类 不再支持直接设置音量或将特定音频流静音
  • 相机服务变更
  • dlopen failed: "has text relocations"
  • 电源管理
    在原有的电源管理的基础上加入了两种新的状态:
  • 规范化App Link (应用程序链接)
  • 指纹识别(统一API)

  • 相关文章

      暂无相关文章

    用户评论