今天项目的bug:
android.os.FileUriExposedException: file:///storage/emulated/0/DCIM/Camera/20180121181328.jpg exposed beyond app through ClipData.Item.getUri()
build.gradle中加入:
<provider
android:authorities="你自己的应用名字.fileprovider"
android:name="android.support.v4.content.FileProvider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths"/>
</provider>
配置filepaths
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path path="myfile/" name="path" />
</paths>
files-path代表的根目录: Context.getFilesDir()
external-path代表的根目录: Environment.getExternalStorageDirectory()
cache-path代表的根目录: getCacheDir()
path 代表要共享的目录
name 只是一个标示