### Install PermissionHelper with Gradle Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Add the PermissionHelper library to your Android project by including this dependency in your build.gradle file. This line specifies the library's group, artifact, and version. ```groovy compile 'com.github.k0shk0sh:PermissionHelper:1.1.0' ``` -------------------------------- ### Install PermissionHelper with Maven Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Integrate the PermissionHelper library into your Maven-based Android project by adding this dependency block to your pom.xml. It defines the necessary group, artifact, version, and type for the AAR package. ```xml com.github.k0shk0sh PermissionHelper 1.1.0 aar ``` -------------------------------- ### Get Declined Permissions (Multiple) Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Retrieves an array of declined permission strings. This method can be called using either `PermissionHelper` or `PermissionFragmentHelper` instances or statically. It takes a Context/Fragment and an array of permissions as input. ```APIDOC public static String[] declinedPermissions(@NonNull Context/Fragment context, @NonNull String[] permissions) ``` -------------------------------- ### Get Declined Permission (Single) Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Retrieves a single declined permission string. This method can be called using either `PermissionHelper` or `PermissionFragmentHelper` instances or statically. It takes a Context/Fragment and an array of permissions as input. ```APIDOC public static String declinedPermission(@NonNull Context/Fragment context, @NonNull String[]) ``` -------------------------------- ### Request Permissions in Android Fragment Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md This code demonstrates how to request permissions from within an Android Fragment. Similar to the Activity method, setForceAccepting can be configured, and request is called to prompt the user for the specified permissions. ```java permissionFragmentHelper .setForceAccepting(false)// true if you had like force reshowing the permission dialog on Deny (not recommended) .request(isSingle ? SINGLE_PERMISSION : MULTIPLE_PERMISSIONS); ``` -------------------------------- ### Request Permissions Without Explanation Dialog Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md To request a permission without displaying an explanation message, even if the user declines, set setSkipExplanation(true) before calling request. This is useful for permissions where an immediate prompt is preferred. ```java permissionHelper .setSkipExplanation(true)// true if you don't want to show expalanation message .request(CAMERA_PERMISSION); ``` -------------------------------- ### Open Application Settings Screen Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Opens the application's settings screen, which is useful when a permission cannot be requested again due to permanent denial. This method can be called using either `PermissionHelper` or `PermissionFragmentHelper` instances or statically. It takes a Context/Fragment as input. ```APIDOC public static void openSettingsScreen(Context/Fragment context) ``` -------------------------------- ### Check if Permission Explanation is Needed Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Determines if an explanation should be shown to the user for a specific permission. This method can be called using either `PermissionHelper` or `PermissionFragmentHelper` instances or statically. It returns true if an explanation is needed. Requires an Activity/Fragment and the permission name. ```APIDOC public static boolean isExplanationNeeded(@NonNull Activity/Fragment context, @NonNull String permissionName) ``` -------------------------------- ### Request Permissions in Android Activity Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Use this snippet within an Android Activity to initiate a permission request. The setForceAccepting method controls whether the permission dialog is re-shown on denial, and request triggers the permission flow for single or multiple permissions. ```java permissionHelper .setForceAccepting(false)// true if you had like force reshowing the permission dialog on Deny (not recommended) .request(isSingle ? SINGLE_PERMISSION : MULTIPLE_PERMISSIONS); ``` -------------------------------- ### OnPermissionCallback Interface Methods Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md The OnPermissionCallback interface defines methods for handling various permission request outcomes. Implement this interface in your Activity, Fragment, or Presenter to receive notifications when permissions are granted, declined, need explanation, or are pre-granted. ```APIDOC void onPermissionGranted(String[] permissionName); void onPermissionDeclined(String[] permissionName); void onPermissionPreGranted(String permissionsName); void onPermissionNeedExplanation(String permissionName); void onPermissionReallyDeclined(String permissionName);//user has ticked don't show again and deny the permission void onNoPermissionNeeded(); // fallback to api < M ``` -------------------------------- ### Check if SYSTEM_ALERT_WINDOW Permission is Granted Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Checks the special case for `SYSTEM_ALERT_WINDOW` permission. This method can be called using either `PermissionHelper` or `PermissionFragmentHelper` instances or statically. It returns true if granted. Requires a Context/Fragment. This method is targeted for API level M (23) and above. ```APIDOC @TargetApi(Build.VERSION_CODES.M) public static boolean isSystemAlertGranted(@NonNull Context/Fragment context) ``` -------------------------------- ### Forward onRequestPermissionsResult to PermissionHelper Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md After overriding onRequestPermissionsResult in your Activity or Fragment, ensure you call permissionHelper.onRequestPermissionsResult(...) to allow the library to process the permission outcomes and trigger the appropriate callbacks. ```java permissionHelper.onRequestPermissionsResult(....) ``` -------------------------------- ### Check if Permission is Permanently Denied Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Checks if a specific permission has been permanently denied by the user (e.g., 'Don't ask again' was ticked). This method can be called using either `PermissionHelper` or `PermissionFragmentHelper` instances or statically. It returns true if permanently denied. Requires an Activity/Fragment and the permission name. ```APIDOC public static boolean isPermissionPermanentlyDenied(@NonNull Activity/Fragment context, @NonNull String permission) ``` -------------------------------- ### Check if Permission Exists Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Checks if a specific permission is declared in the application's manifest. This method can be called using either `PermissionHelper` or `PermissionFragmentHelper` instances or statically. It returns true if it exists. Requires a Context/Fragment and the permission name. ```APIDOC public static boolean permissionExists(@NonNull Context/Fragment context, @NonNull String permissionName) ``` -------------------------------- ### Check if Permission is Declined Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Checks if a specific permission has been declined. This method can be called using either `PermissionHelper` or `PermissionFragmentHelper` instances or statically. It returns true if declined, false otherwise. Requires a Context/Fragment and the permission name. ```APIDOC public static boolean isPermissionDeclined(@NonNull Context/Fragment context, @NonNull String permission) ``` -------------------------------- ### Check if Permission is Granted Source: https://github.com/k0shk0sh/permissionhelper/blob/master/README.md Checks if a specific permission has been granted. This method can be called using either `PermissionHelper` or `PermissionFragmentHelper` instances or statically. It returns true if granted, false otherwise. Requires a Context/Fragment and the permission name. ```APIDOC public static boolean isPermissionGranted(@NonNull Context/Fragment context, @NonNull String permission) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.