Giter VIP home page Giter VIP logo

callbackpermission's Introduction

Callback permission

android runtime permission 요청을 간단한 콜백 구조로 제공합니다.

자세한 사용법은 sample을 참고해주세요.

사용 방법

기본 설정

Activity 또는 Fragment class 내에서 CallbackPermission 인스턴스를 생성합니다.

CallbackPermission은 내부에서 ActivityResultLauncher를 사용하기 떄문에 onCreate 이전에 인스턴스 생성이 이뤄져야합니다.

class TestActivity : AppCompatActivity() {
    private val callbackPermission: CallbackPermission = callbackPermission()
}

권한 요청

fun requestPermission(vararg permissions: String, callback: PermissionCheckCallBack)을 호출하여 Runtime permission을 요청합니다.

callback으로 허용되지 않은 권한 목록을 받습니다.

callbackPermission.requestPermission(Manifest.permission.ACCESS_COARSE_LOCATION) { deniedPermissions ->
    Snackbar.make(binding.root, deniedPermissions.toString(), Snackbar.LENGTH_LONG).show()
}

권한 허용 여부 체크

fun hasPermissions(vararg permissions: String): Boolean을 호출하여 varargs로 주어진 권한 모두가 허용됐는지 체크합니다.

val isPermitted = callbackPermission.hasPermissions(Manifest.permission.ACCESS_COARSE_LOCATION)

TBD

library를 mavencentral로 배포

callbackpermission's People

Contributors

ehk00 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.