作家
登录

Android 7.0动态权限大总结

作者: 来源: 2017-08-15 09:26:48 阅读 我要评论

 || file == null) { 
  •          return null
  •       } 
  • //收集路径的特别处理,不须要7.0适配,但必须用parse()办法 
  •       if (file.getPath().startsWith("http")) { 
  •          return Uri.parse(file.getPath()); 
  •       } 
  •       Uri uri = null
  •       try { 
  •          if (isNeedAdapt()) { 
  • //须要7.0特别适配 
  • //经由过程体系供给的FileProvider类创建一个content类型的Uri对象 
  •             uri = FileProvider.getUriForFile(context, AUTHORITIES, file); 
  •          } else { 
  • //不须要适配 
  •             uri = Uri.fromFile(file); 
  •          } 
  •       } catch (Exception e) { 
  •          Log.e(TAG, "authorities value error, so can't convert uri !"); 
  •          e.printStackTrace(); 
  •       } 
  •       return uri; 
  •    } 
  •   
  •    /** 
  •     * 对第三方应用付与对uri读写的权限 
  •     * 
  •     * @param context 
  •     * @param intent 
  •     * @param saveUri 适配后的uri 
  •     */ 
  •    public static void grantUriPermission(Context context, Intent intent, Uri saveUri) { 
  •       if (!isNeedAdapt()) { 
  •          return
  •       } 
  •       if (context == null || intent == null || saveUri == null) { 
  •          return
  •       } 
  • //收集路径的特别处理,不须要权限 
  •       if (saveUri.getScheme() != null && saveUri.getScheme().startsWith("http")) { 
  • //不须要授权 
  •          return
  •       } 

      推荐阅读

      什么是云原生应用 有哪些关键点?

    比来评论辩论云原生应用越来越多,其是指原生为在云平台上安排运行而设计开辟的应用。公平的说,大年夜多半传统的应用,不做任何修改,都是可以在云平台运行起来的,只要云平台支撑这个传>>>详细阅读


    本文标题:Android 7.0动态权限大总结

    地址:http://www.17bianji.com/lsqh/36701.html

  • 关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)