1.权限申请
8.0以后需要。
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
2.清单文件
8.0后通过FileProvider方式
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
其中 file_paths 对应的文件内容,表示源的来源:
// 该方式提供在外部存储区域根目录下的文件。它对应 Environment.getExternalStorageDirectory返回的路径:eg:"/storage/emulated/0";
<external-path name="name" path="path" />
// 该方式提供在应用的外部存储区根目录的下的文件。它对应 Context#getExternalFilesDi