A simple easy-to-use permission helper for Android. No need to handle result in onActivityResult and passing it to fragment or model. PermissionUtil can be used from any place with context only (Activity, Fragment,ViewModel).
//Easy to use
PermissionUtil.locationBoth(context, requestPermissionListener);
Simplified callback. Just override method that you need and that's it.
public abstract class ShortPerCallback implements PermissionCallback {
@Override
public void onPermissionGranted() {
}
@Override
public void onPermissionDenied() {
}
}
You can directly use prepared requests like :
PermissionUtil.locationFine(context, requestPermissionListener);
PermissionUtil.locationCoarse(context, requestPermissionListener);
Or you can request multiple permissions with your group :
PermissionUtil.checkGroup(context, requestPermissionListener,new String[]{Manifest.permission.READ_PHONE_STATE});
List of permissions that could be requested according to Dangerous permissions :
- contactsRead
- contactsWrite
- contactsRW
- calendarRead
- calendarWrite
- calendarRW
- storageRead
- storageWrite
- storageRW
- locationFine
- locationCoarse
- locationBoth
- camera
- microphone
- phoneReadState
- phoneCall
- phoneReadCallLog
- phoneWriteCallLog
- phoneAddVoiceMail
- phoneSip
- phoneOutgoing
- phoneAll
- sensors
- smsSend
- smsReceive
- smsRead
- smsWap
- smsMms
- smsAll
- checkGroup
repositories {
// yo can use
mavenCentral() // or jcenter()
//or direct link to repository or jitpack
maven { url "http://dl.bintray.com/euzee/Libs" } // or maven { url "https://jitpack.io" }
}
compile 'com.github.euzee:permissionUtil:1.0.2'
Copyright 2017 Euzee, Inc.
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.