Giter Site home page Giter Site logo

mpermissionlib's Introduction

Android M 权限请求类库

本类库中包含一个在Android M及以下版本中实现权限请求的Activity基类

使用方法

gradle

在dependencies中加入 compile 'me.yaog:mpermissionlib:0.0.1'

自行编译

下载mpermissionlib/src/main/java/me/yaog/mpermissionlib/MActivity.java

用法示例

自定义Activity继承MActivity, 在需要获取文件读写权限时,执行如下方法

boolean hasPermission = requirePermissions(1, new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
android.Manifest.permission.READ_EXTERNAL_STORAGE}, new PermissionEvent(){
    @Override
    void permissionGranted() {
        doOperation();
    }
    @Override
    void permissionDenied(String[] permissions) {
        Toast.makeText(this,"PermissionDenied",Toast.LENGTH_SHORT).show();
    }
});
if(hasPermission) {
    doOperation();
}

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.