Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ssseasonnn/PermissionX
Android permission with coroutine
https://github.com/ssseasonnn/PermissionX
Last synced: 21 days ago
JSON representation
Android permission with coroutine
- Host: GitHub
- URL: https://github.com/ssseasonnn/PermissionX
- Owner: ssseasonnn
- License: apache-2.0
- Created: 2020-02-16T09:19:41.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-02T07:06:32.000Z (about 3 years ago)
- Last Synced: 2024-08-05T17:38:53.557Z (4 months ago)
- Language: Kotlin
- Size: 149 KB
- Stars: 35
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-hacking-lists - ssseasonnn/PermissionX - Android permission with coroutine (Kotlin)
README
# PermissionX
[![](https://jitpack.io/v/ssseasonnn/PermissionX.svg)](https://jitpack.io/#ssseasonnn/PermissionX)
申请权限也能使用协程?Why not?
## 准备
1. Add jitpack to build.gradle
```gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```2. Add dependency
```gradle
dependencies {
implementation 'com.github.ssseasonnn:PermissionX:1.0.2'
}
```## 使用方法
权限申请只需一行代码
```kotlin
launch {
try {
val result = request(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE)
if (result.isGranted) {
//Now we have storage permission.
}else {
if (result.shouldShowRational) {
//Show permission rational
}
if (result.alwaysDenied) {
//User always denied our permission
}
}
} catch (t: Throwable) {
Log.w("TAG", t)
}
}
```## License
> ```
> Copyright 2021 Season.Zlc
>
> 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.
> ```