Giter Club home page Giter Club logo

permissionmanager's Introduction

android6.0之前,当我们需要使用到存储权限时(如创建目录,保存图片等操作),我们只需要在AndroidManifest.xml中申明权限即可

但是在android6.0之后除了在AndroidManifest.xml中申明权限之外,我们还需要在代码中动态申请权限,让用户确认才可以

这对于刚刚接触android6.0的开发者来说就是一个坑

有时候在之前的手机上正常运行的应用,在新手机上就出现各种莫名其妙的问题,因此为了不让更多人掉坑里,我这里分享一下我权限申请的步骤。

这里面的工具相关的代码也是参考之前github上别人分享的,不过他的代码太过复杂,所以我这里抽取出来并且以实际demo的形式来演示如何动态申请权限,供大家参考。

导入包:

implementation 'com.zengyu:permission:1.0.0'

使用步骤:

  1. 定义PermissionHelper变量。
  2. 在需要检查权限的地方调用doPermissionCheck()方法。
  3. 实现OnPermissionCallback回调接口。
  4. 在实现的回调方法里面做各自的事情。具体可以看注释。也可以通过添加日志的方式来观察。

欢迎star和follow

请求权限图片

参考的原github传送门

permissionmanager's People

Contributors

zhanzengyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.