This is probably the easiest permission request framework to use

Github shipping address, welcome Star

In addition to Android 6.0 permissions need in-depth understanding, you can see this article Android 6.0 running permissions parsing (advanced)

The integration steps

Dependencies {implementation 'com. HJQ: xxpermissions: 5.2'}Copy the code

Handling permission requests in one line of code has never been easier

See the full sample code here

XXPermissions. With (this) //.constantrequest () // //.permission(permission.system_alert_window, Permission. REQUEST_INSTALL_PACKAGES) / / support requests suspension Windows 6.0 8.0 request installation permissions. The permissions Permission (Permission) Group) STORAGE, Permission. Group. The CALENDAR) / / no specified permissions automatically retrieve dangerous permissions in the listing. The request (new OnPermission () {@ Override public void hasPermission(List<String> granted, boolean isAll) { } @Override public void noPermission(List<String> denied, boolean quick) { } });Copy the code

Whether you have this permission

if (XXPermissions.isHasPermission(this, Permission.Group.STORAGE)) {
	
}
Copy the code

The Settings page is displayed

XXPermissions.gotoPermissionSettings(this);
Copy the code

The framework highlights

  • Simple and easy to use, using the way of chain call, use only one line of code

  • Supports single permission, multiple permission, single permission group, and multiple permission group requests

  • If you do not specify permissions, the system automatically obtains dangerous permissions from the list file and applies for them

  • An exception is thrown if dynamically requested permissions are not registered in the manifest file

  • Support most domestic mobile phones directly jump to the specific permission setting page

  • The application can be set to continue after being rejected until the user is authorized or permanently rejected

  • Support request 6.0 and above hover window permissions and 8.0 and above installation permissions

  • The framework does not rely on the AppCompatSupport library and is compatible with Eclipse and Studio

Confusing rules

-dontwarn com.hjq.permissions.**
Copy the code

Q&A

As we all know, only the hasPermission method is called if the user grants all, and only the noPermission method is called if the user refuses all.

But how does the framework handle callbacks in cases where multiple permissions are requested and not all of them are granted or denied, but some of them are granted and some of them are denied?

The framework calls the noPermission method first and then the hasPermission method. We can use the isAll parameter in the hasPermission method to determine whether all permissions are granted. If you want to know whether a Permission in a callback is granted or denied, you can call the contains(Permission.xxx) method in the List collection class to determine whether the collection contains the Permission.

From the voice of a small white user

He may be debauched in behavior and language and lewd in appearance, but inside, he is pure

Android Technology discussion Q group: 78797078

Remember to like + at the endStar