Code Monkey home page Code Monkey logo

xpermissions's Introduction

XPermissions 👋

XPermission

Hex.pm badgeGitHub release (latest by date)

An easy to use open source library using in the kotlin

这是一个基于 Kotlin 的简单易用的权限申请库

How to Use

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.LoveLifeEveryday:XPermissions:1.0.0'
	}

Step 3.Use it in your project

XPermission.request(
    this,
    // 这里的权限可以是单个或者多个,权限之间用逗号『,』隔开即可
    Manifest.permission.XXX1,
    Manifest.permission.XXX2,
    // allGranted 是一个 boolean 类型的变量,若为 true ,则所有权限申请通过
    // deniedList 是一个 List 类型的变量,表示用户拒绝权限列表
) { allGranted, deniedList ->
    if (allGranted) {
        Toast.makeText(this, "All permissions are granted", Toast.LENGTH_SHORT).show()
    } else {
        Toast.makeText(this, "You denied $deniedList", Toast.LENGTH_SHORT).show()
    }
}

Demo

测试用的 Demo

How to create this

为了方便读者们了解编写『请求框架』以及发布到 JitPack 的一系列流程,笔者特意写了一篇文章来阐述:

带你封装自己的『权限管理』框架

Author

👤 许朋友爱玩

Show your support

Give a ⭐️ if this project helped you!

求星星⭐️,求赞👍

xpermissions's People

Contributors

lovelifeeveryday avatar

Watchers

 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.