Guest User

Untitled

a guest
Nov 19th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. android N 开始不允许以 `file://` 的方式通过 `Intent` 在两个 App 之间分享文件,取而代之的是通过 `FileProvider` 生成 `content://Uri`
  2.  
  3. 这要求分享文件的两个 App 都需要支持这种新的 `schema`, 而事实并非如此。大量的第三方应用还并未支持这种新的文件共享方式。巨头应用微博就是其中之一。
  4.  
  5. 为了更好的适配这些第三方应用,可以使用下面两种解决方式:
  6.  
  7.  
  8. 1. 更改 targetSdkVersion 到 24 以下
  9.  
  10. 2. StrictMode 不设置 detectFileUriExposure
  11. ```
  12. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
  13. StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
  14. StrictMode.setVmPolicy(builder.build());
  15. }
  16.  
  17. ```
Add Comment
Please, Sign In to add comment