### Explaining Reason Before Requesting Permissions Source: https://github.com/guolindev/permissionx/blob/master/README.md Shows how to use the `explainReasonBeforeRequest` method to proactively display a rationale dialog before the initial permission request, improving user experience. ```kotlin PermissionX.init(activity) .permissions(Manifest.permission.READ_CONTACTS, Manifest.permission.CAMERA, Manifest.permission.CALL_PHONE) .explainReasonBeforeRequest() ... ``` -------------------------------- ### Requesting Permissions with Rationale Dialog Source: https://github.com/guolindev/permissionx/blob/master/README.md Demonstrates how to request permissions and provide a rationale dialog to the user if permissions are denied. The `onExplainRequestReason` callback allows for custom dialogs to explain the necessity of permissions. ```kotlin PermissionX.init(activity) .permissions(Manifest.permission.READ_CONTACTS, Manifest.permission.CAMERA, Manifest.permission.CALL_PHONE) .onExplainRequestReason { scope, deniedList -> scope.showRequestReasonDialog(deniedList, "Core fundamental are based on these permissions", "OK", "Cancel") } .request { allGranted, grantedList, deniedList -> if (allGranted) { Toast.makeText(this, "All permissions are granted", Toast.LENGTH_LONG).show() } else { Toast.makeText(this, "These permissions are denied: $deniedList", Toast.LENGTH_LONG).show() } } ``` -------------------------------- ### Handling Denied Permissions and Forwarding to Settings Source: https://github.com/guolindev/permissionx/blob/master/README.md Illustrates how to handle cases where users deny permissions and select 'never ask again'. The `onForwardToSettings` callback prompts the user to manually enable permissions in the app's settings. ```kotlin PermissionX.init(activity) .permissions(Manifest.permission.READ_CONTACTS, Manifest.permission.CAMERA, Manifest.permission.CALL_PHONE) .onExplainRequestReason { scope, deniedList -> scope.showRequestReasonDialog(deniedList, "Core fundamental are based on these permissions", "OK", "Cancel") } .onForwardToSettings { scope, deniedList -> scope.showForwardToSettingsDialog(deniedList, "You need to allow necessary permissions in Settings manually", "OK", "Cancel") } .request { allGranted, grantedList, deniedList -> if (allGranted) { Toast.makeText(this, "All permissions are granted", Toast.LENGTH_LONG).show() } else { Toast.makeText(this, "These permissions are denied: $deniedList", Toast.LENGTH_LONG).show() } } ``` -------------------------------- ### Request Permissions with PermissionX Source: https://github.com/guolindev/permissionx/blob/master/README.md Use PermissionX to easily request multiple runtime permissions. The callback provides information on granted and denied permissions. ```kotlin PermissionX.init(activity) .permissions(Manifest.permission.READ_CONTACTS, Manifest.permission.CAMERA, Manifest.permission.CALL_PHONE) .request { if (allGranted) { Toast.makeText(this, "All permissions are granted", Toast.LENGTH_LONG).show() } else { Toast.makeText(this, "These permissions are denied: $deniedList", Toast.LENGTH_LONG).show() } } ``` -------------------------------- ### Add PermissionX Dependency Source: https://github.com/guolindev/permissionx/blob/master/README.md Add the PermissionX library to your project's build.gradle file to enable its functionality for runtime permission requests. ```groovy repositories { google() mavenCentral() } dependencies { implementation 'com.guolindev.permissionx:permissionx:1.8.1' } ``` -------------------------------- ### Apache License 2.0 Source: https://github.com/guolindev/permissionx/blob/master/README.md The Apache License, Version 2.0, is a permissive free software license written by the Apache Software Foundation (ASF). It allows users to freely use, modify, and distribute the software for commercial and non-commercial purposes. ```text Copyright (C) guolin, PermissionX Open Source Project 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. ``` -------------------------------- ### Declare Permissions in AndroidManifest Source: https://github.com/guolindev/permissionx/blob/master/README.md Declare the necessary runtime permissions in your AndroidManifest.xml file before requesting them using PermissionX. ```xml ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.