• android适配知识总结


    一、http适配

      背景:API升级到28以后,不再支持明文的网络请求,只支持https请求。运行所报错误:java.net.UnknownServiceException: CLEARTEXT communication ** not permitted by network security policy

      解决方案:

        1、//.在res目录下,新建xml目录,在xml目录下新建`network_security_config.xml`文件

         <?xml version="1.0" encoding="utf-8"?>
         <network-security-config>
           <base-config cleartextTrafficPermitted="true" />
         </network-security-config>

        2、在manifest的application下设置如下属性

          android:networkSecurityConfig="@xml/network_security_config"

    二、对18:9的屏幕适配

      背景:会出现上下黑边的情况.

      解决方案:

        在AndroidManifest.xml文件中,对application做一下处理,如下所示。

        <application>

        .............

        <meta-data android:name="android.max_aspect" android:value="2.1" />

        .............

        </application>

    
    

    三、对webview是否使用明文流量的适配

      背景:targetSdkVersion为27或更低的应用程序的android:usesCleartextTraffic默认值为“ true”。面向API级别28或更高级别的应用默认为“ false”时,webview加载不出来界面。

      解决方案:

        在AndroidManifest.xml文件中,给application标签的android:usesCleartextTraffic属性设置为true。

  • 相关阅读:
    [转]Entity Framework 和NHibernate的区别
    NHibernate One Session Per Request简单实现
    memcache和memcached之间的区别
    Memcached 内存分配机制介绍
    linux,apache,php,mysql常用的查看版本信息的方法
    Linux查看文件夹大小
    Linux查看系统配置常用命令
    php 文件缓存(转)
    memcache在xampp下的安装
    通过改进代码将for循环遍历数组提高效率
  • 原文地址:https://www.cnblogs.com/qynprime/p/11959164.html
Copyright © 2020-2023  润新知