Reactive implementation of Android runtime permissions using RxJava3.
This library provides simple and lightweight apis that emitts PermissionResult
.
Requesting for permissions:
RxPermissions(this).request(...)
Request for permission results (skips granted permission results):
RxPermissions(this).requestSkipGranted(...)
Request for simple permission (Emitts true
or false
):
RxPermissions(this).requestSimple(...)
The PermissionResult
model:
PermissionResult.index // The index of requesting permission order
PermissionResult.permission // Manifest.permission.XXX
PermissionResult.granted // true or false
PermissionResult.rationale // true or false
Incase of Android version < M, result is always true.
- Already granted permission results are emitted as soon as requested with
.request(...)
method. (Eg. If camera permission is already granted, you can start the camera related work, while Android system is asking for remaining permission) - Use
.requestSkipGranted(...)
method to skip the results of already granted permission results. - Use
.requestSimple(...)
method to get justtrue
orfalse
values, if you don't care about rationale permission results.
implementation 'com.abarajithan.rxpermissions:rxpermissions:1.0.0-beta'
You need to add jcenter()
to project level build.gradle
file.
Copyright 2020 Abarajithan Lv
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.