Android 原生场景的两个配置

一、Android 7.0 的file_paths配置

1、在工程res目录下新建xml目录创建file_paths.xml文件

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <root-path name="root" path="."/>
    <files-path name="files" path="." />
    <cache-path name="cache" path="." />
    <external-path name="external" path="." />
    <external-files-path name="name" path="path" />
    <external-cache-path name="name" path="path" />
</paths>

2、在AndroidManifest.xml中配置

<provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="com.byd.customer_services.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true"
            tools:ignore="WrongManifestParent">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>

二、在android p之后

1、networkSecurityConfig配置

google在android p为了安全起见,已经明确规定禁止http协议额,但是之前很多接口都是http协议,我们一般是这样解决的:

在res目录下创建xml目录,然后随便创建一个network_security_config.xml文件,里面内容如下:

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

2、在AndroidManifest.xml文件下加上:

android:networkSecurityConfig="@xml/文件名"

 <application
        android:name=".BydApplication"
        android:allowBackup="false"
        android:hardwareAccelerated="true"
        android:icon="@mipmap/byd_logo"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:roundIcon="@mipmap/byd_logo"
        android:supportsRtl="false"
        android:theme="@style/AppTheme">
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值