Skip to content

The demo provided by this project can help you easily apply for dynamic permissions.

Notifications You must be signed in to change notification settings

jinshenglongsw/PermissionUtils

Repository files navigation

How to use:

1.import PermissionsUtils.java

2.use this code:

//add permission for the list..and register permission for the manifast.xml. 
String[] permissions = new String[]{Manifest.permission.CAMERA};
//and like this.
PermissionsUtils.getInstance().checkPermissions(MainActivity.this, permissions, permissionsResult, CAMERA_REQUEST_CODE);

3.//implements interface

@Override
public void permissionPass() {
    Toast.makeText(activity, "pass", Toast.LENGTH_SHORT).show();
}

@Override
public void permissionNoPass() {
    Toast.makeText(activity, "no pass", Toast.LENGTH_SHORT).show();
}

@Override
public void permissionNoPassNaver() {
    Toast.makeText(activity, "no pass naver show again", Toast.LENGTH_SHORT).show();
}

4.//create permission request callback.

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);

switch (requestCode) {
    case CAMERA_REQUEST_CODE:
        PermissionsUtils.getInstance().onRequestPermissionsResult(this, permissions, grantResults);
        break;
    }
}
  1. finish.

About

The demo provided by this project can help you easily apply for dynamic permissions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages