A lightweight android permission manager.
The latest version 2.0 supports Chain-style, currently.
Chinese
allprojects {
repositories {
maven {
url 'https://oss.sonatype.org/content/groups/public'
}
}
}
implementation 'com.uniquext.android:permission:2.1.2-SNAPSHOT'
LightPermission
.with(this)
.permissions(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE)
.request(new PermissionCallback() {
@Override
public void onGranted() {
// Camera and storage permissions have been acquired
}
@Override
public void onDenied(String[] permissions) {
// Permission set rejected on request
}
@Override
public void onProhibited(String[] permissions) {
// The permission set is set to "Do not ask again after prohibition"
new AppSettingsDialog.Builder(this) .show();
}
});
LightPermission
.with(this)
.permissions(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE)
.grant(() -> {
// Camera and storage permissions have been acquired
})
.deny(permissions -> {
// Permission set rejected on request
})
.prohibit(permissions -> {
// The permission set is set to "Do not ask again after prohibition"
new AppSettingsDialog.Builder(this) .show();
})
.request();
with(this)
- The
this
parameter can be aFragmentActivity
orFragment
(when usingandroidx.fragment.app
package). - And can also be a
Activity
orandroid.app.Fragment
(when usingandroid.app
package).
permissions
The permission which to be requested, at least one in number.
result(new PermissionCallback())
permission callback
onGranted
Called when all requested permissions are granted.onDenied
Called when there is a denied permission, the parameterpermissions
is the denied permission set.onProhibited
Called when there is a denied permissions and those were set to no longer ask, the parameterpermissions
is the set of permissions that were set to no longer ask.
- Click Here to look instructions of version 1.x.
- The library is currently in beta, but I have not encountered any issue in actual projects.
- Welcome everyone to contribute code and comments.
- If you feel ok, please click Star.
Copyright Haitao Peng
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.