Giter Site home page Giter Site logo

smallpermissions's Introduction

SmallPermissions

简介

Android 权限框架

用法

用法一

使用注解,现支持普通方法以及静态方法,如果没有权限方法体里面的代码不会执行

//参数一 String[]:需要获取的权限
//参数二 int:如果没有权限时的提示
//参数三 boolean:是否打开设置页面(可不填)
@PermissionsApply(
            permissions = {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION},
            hint = R.string.app_hint, openSetting = false)
public void test(){

}

用法二

调用方法,

//with 参数 Object:传入 Context、Fragment、Activity、Dialog 等,如果获取不到这些对象可以传 null
//permission 参数 String[]:需要获取的权限
//onGranted 参数 Action:成功回调
//onDenied 参数 Action:失败回调
 SmallPermission.with(this)
            .permission(permissions)
            .onGranted(new Action() {
              @Override
              public void onAction(List<String> Permissions) {
                Toast.makeText(SampleActivity.this, "成功", Toast.LENGTH_SHORT).show();
              }
            })
            .onDenied(new Action() {
              @Override
              public void onAction(List<String> Permissions) {
                Toast.makeText(SampleActivity.this, "失败", Toast.LENGTH_SHORT).show();
              }
            })
            .start();

Todo List

  1. 适配国内机型

smallpermissions's People

Contributors

quincysx avatar

Stargazers

Howard avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

sunbird89629

smallpermissions's Issues

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.