Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Tedpermission | 1,572 | 2 years ago | 8 | October 27, 2021 | 22 | Java | ||||
Easy check permission library for Android Marshmallow | ||||||||||
Runtimepermission | 868 | 3 years ago | 5 | apache-2.0 | Java | |||||
Simpliest way to ask runtime permissions on Android, no need to extend class or override permissionResult method, choose your way : Kotlin / Coroutines / RxJava / Java7 / Java8 | ||||||||||
Unityandroidpermissions | 98 | 5 years ago | 1 | mit | C# | |||||
Unity Android Runtime Permissions for Android Marshmallow | ||||||||||
Wpandroidpermissions | 66 | 8 years ago | 1 | Java | ||||||
Permissionhelper | 65 | 3 years ago | apache-2.0 | Kotlin | ||||||
PermissionHelper for Android M, Kotlin best way | ||||||||||
Selfie | 56 | 7 years ago | apache-2.0 | Java | ||||||
A simple library to make taking screenshots of your apps a breeze. | ||||||||||
Custompermissionsdialogue | 53 | 4 years ago | n,ull | Java | ||||||
Custom Permissions Dialogue is the only permissions library that supports ALL permission request scenarios. This library handles multiple edge cases such as not enabling all permissions or permanently rejecting a permission request. | ||||||||||
Android Permissions Manager | 51 | 5 years ago | 2 | Kotlin | ||||||
Easily manage Android Marshmallow and up runtime permissions. | ||||||||||
Android Permissions Gradle Plugin | 39 | 6 years ago | apache-2.0 | Kotlin | ||||||
Plugin generating a helper class to deal with the new Permissions System in Marshmallow | ||||||||||
Easypermissions | 36 | 2 years ago | ||||||||
Request permissions from anywhere as long as you have context. |
After the update to Android 6.0 Marshmallow, we have to not only declare permissions in AndroidManifest.xml
, but also request them at runtime. Furthermore, the user can turn permissions on/off anytime in application settings.
When you use dangerous permissons(ex. CAMERA
, READ_CONTACTS
, READ_PHONE_STATE
, ...), you must check and request them at runtime.
(https://developer.android.com/guide/topics/permissions/overview?hl=en#normal-dangerous)
You can make your own permission check logic like this, but it's very complex, mainly because functions Google offer are very hard to use: checkSelfPermission()
, requestPermissions()
, onRequestPermissionsResult()
, onActivityResult()
.
TedPermission makes it easy to check and request android permissions.
(For Korean)
아래 블로그를 통해 마시멜로우 권한 관련된 사항을 알아보세요
http://gun0912.tistory.com/55
root/app/build.gradle
like below.normal
/coroutine
/rxJava2
/rxJava3
x.y.z
with the version shown in the 'Maven Central' button below, or the specific version you want (e.g. replace x.y.z
with 3.3.0
if you want v3.3.0).repositories {
google()
mavenCentral()
}
dependencies {
// Normal
implementation 'io.github.ParkSangGwon:tedpermission-normal:x.y.z'
// Coroutine
implementation 'io.github.ParkSangGwon:tedpermission-coroutine:x.y.z'
// RxJava2
implementation 'io.github.ParkSangGwon:tedpermission-rx2:x.y.z'
// RxJava3
implementation 'io.github.ParkSangGwon:tedpermission-rx3:x.y.z'
}
If you think this library is useful, please press the star button at the top.
We will use PermissionListener
for handling permission check result.
You will get the result to onPermissionGranted()
or onPermissionDenied()
depending on approved permissions.
PermissionListener permissionlistener = new PermissionListener() {
@Override
public void onPermissionGranted() {
Toast.makeText(MainActivity.this, "Permission Granted", Toast.LENGTH_SHORT).show();
}
@Override
public void onPermissionDenied(List<String> deniedPermissions) {
Toast.makeText(MainActivity.this, "Permission Denied\n" + deniedPermissions.toString(), Toast.LENGTH_SHORT).show();
}
};
TedPermission class requires setPermissionListener()
, setPermissions()
, and check()
methods.
Call check()
to start checking for permissions.
setRationaleMessage()
and setDeniedMessage()
are optional methods for displaying messages.
TedPermission.create()
.setPermissionListener(permissionlistener)
.setDeniedMessage("If you reject permission,you can not use this service\n\nPlease turn on permissions at [Setting] > [Permission]")
.setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.ACCESS_FINE_LOCATION)
.check();
If you use kotlin and coroutine, You can use check()
function.
TedPermissionResult
instance has isGranted()
, getDeniedPermissions()
methods for checking permission check result.
val permissionResult =
TedPermission.create()
.setPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION)
.check()
Also if you want know only granted result, you can use checkGranted(): boolean
If you use RxJava, You can use request()
method instead check()
.
When permission check has finished, you will receive TedPermissionResult
instance.
TedPermissionResult
instance has isGranted()
, getDeniedPermissions()
methods for checking permission check result.
TedPermission.create()
.setRationaleTitle(R.string.rationale_title)
.setRationaleMessage(R.string.rationale_message) // "we need permission for read contact and find your location"
.setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.ACCESS_FINE_LOCATION)
.request()
.subscribe(tedPermissionResult -> {
if (tedPermissionResult.isGranted()) {
Toast.makeText(this, "Permission Granted", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this,
"Permission Denied\n" + tedPermissionResult.getDeniedPermissions().toString(), Toast.LENGTH_SHORT)
.show();
}
}, throwable -> {
});
TedPermission supports the following methods.
setGotoSettingButton(boolean) (default: true)
setRationaleTitle(R.string.xxx or String)
setRationaleMessage(R.string.xxx or String)
setRationaleConfirmText(R.string.xxx or String) (default: confirm / 확인)
setDeniedTitle(R.string.xxx or String)
setDeniedMessage(R.string.xxx or String)
setDeniedCloseButtonText(R.string.xxx or String) (default: close / 닫기)
setGotoSettingButtonText(R.string.xxx or String) (default: setting / 설정)
Also you can use the following utility functions.
isGranted(String... permissions)
: Check if all permissions are grantedisDenied(String... permissions)
: Check if all permissions are deniedgetDeniedPermissions(String... permissions)
canRequestPermission(Activity activity, String... permissions)
: If true
you can request a system popup, false
means user checked Never ask again
.startSettingActivityForResult()
startSettingActivityForResult(int requestCode)
Check permissions -> Already have permissions
: onPermissionGranted()
is called.
Check permissions -> Don't have permissions
: Request dialog is shown.
Show request dialog -> User granted permissions
: onPermissionGranted()
is called.
Show request dialog -> User denied one or more permissions
: Denied dialog is shown.
Show denied dialog -> Close the dialog
: onPermissionDenied()
called
Show denied dialog -> Setting button clicked
: startActivityForResult()
to application Setting Activity.
Setting Activity -> onActivityResult()
: Check permissions again
Check permission -> Permissions are granted
: onPermissionGranted()
is called.
Check permission -> There are denied permissions
: onPermissionDenied()
is called.
Copyright 2021 Ted Park
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.