{"id":18789197,"url":"https://github.com/dsiner/permissioncompat","last_synced_at":"2025-06-16T08:31:52.490Z","repository":{"id":202173174,"uuid":"129329808","full_name":"Dsiner/PermissionCompat","owner":"Dsiner","description":"Android runtime permissions without RxJava2   ——Android 6.0 运行时权限","archived":false,"fork":false,"pushed_at":"2020-12-24T15:25:34.000Z","size":196,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T14:18:04.003Z","etag":null,"topics":["android-permissions","permission","runtime-permissions"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dsiner.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-04-13T01:17:27.000Z","updated_at":"2020-12-24T15:25:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"6c965147-28bf-4914-9e4a-d26dfff26444","html_url":"https://github.com/Dsiner/PermissionCompat","commit_stats":null,"previous_names":["dsiner/permissioncompat"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Dsiner/PermissionCompat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dsiner%2FPermissionCompat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dsiner%2FPermissionCompat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dsiner%2FPermissionCompat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dsiner%2FPermissionCompat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dsiner","download_url":"https://codeload.github.com/Dsiner/PermissionCompat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dsiner%2FPermissionCompat/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260126224,"owners_count":22962605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-permissions","permission","runtime-permissions"],"created_at":"2024-11-07T21:06:56.015Z","updated_at":"2025-06-16T08:31:52.474Z","avatar_url":"https://github.com/Dsiner.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PermissionCompat for Android\n\n[![License](https://img.shields.io/badge/license-Apache%202-green.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n[![API](https://img.shields.io/badge/API-9%2B-green.svg?style=flat)](https://android-arsenal.com/api?level=9)\n[![Download](https://api.bintray.com/packages/dsiner/maven/permissioncompat/images/download.svg) ](https://bintray.com/dsiner/maven/permissioncompat/_latestVersion)\n\n\u003e A library to handle runtime permissions\n\n## Set up\nMaven:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.dsiner.lib\u003c/groupId\u003e\n  \u003cartifactId\u003epermissioncompat\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.3\u003c/version\u003e\n\u003c/dependency\u003e\n```\nor Gradle:\n```groovy\ncompile 'com.dsiner.lib:permissioncompat:1.0.3'\n```\n\n## Features\n- [x] Fully Marshmallow support\n- [x] Xiaomi support\n- [x] Special devices support, such as Xiaomi, Meizu, Oppo, etc. it's not good, can not be 100% supported\n\n## Support level\n- `SUPPORT_LEVEL_M` If you only want to support Marshmallow above. 'Default options'\n- `SUPPORT_LEVEL_M_XIAOMI` If you only want to support Marshmallow above and Xiaomi device.\n- `SUPPORT_LEVEL_L` If you want to support LOLLIPOP above, such as Xiaomi, Meizu, Oppo, etc. Not Suggest\n\n## Initialize in the application\n\n```java\npublic class App extends Application {\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        // Set support level\n        PermissionSupport.setLevel(PermissionSupport.SUPPORT_LEVEL_M_XIAOMI);\n        // You can set the thread pool yourself here, otherwise the default will be used.\n        PermissionSupport.setThreadPool(new ThreadPool() {\n            @Override\n            public void executeMain(Runnable r) {\n                TaskScheduler.executeMain(r);\n            }\n\n            @Override\n            public void executeTask(Runnable r) {\n                TaskScheduler.executeTask(r);\n            }\n\n            @Override\n            public void executeNew(Runnable r) {\n                TaskScheduler.executeNew(r);\n            }\n        });\n    }\n}\n```\n\n## Usage\n\n1. Check whether the permissions are all already granted\n\n```java\nPermissionChecker.isGranted(context, permissions)\nor\nPermissionCompat.hasSelfPermissions(context, permissions)\n```\n\n2. Request permissions\n\n```java\n        PermissionCompat.with(activity)\n                .requestEachCombined(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)\n                .subscribeOn(PermissionSchedulers.io())\n                .observeOn(PermissionSchedulers.mainThread())\n                .requestPermissions(new PermissionCallback\u003cPermission\u003e() {\n                    @Override\n                    public void onNext(Permission permission) {\n                        if (permission.granted) {\n                            // All permissions are granted !\n                            Toast.makeText(getApplicationContext(), \"All permissions are granted\", Toast.LENGTH_SHORT).show();\n                        } else if (permission.shouldShowRequestPermissionRationale) {\n                            // At least one denied permission without ask never again\n                            Toast.makeText(getApplicationContext(), \"Permission without ask never again\", Toast.LENGTH_SHORT).show();\n                        } else {\n                            // At least one denied permission with ask never again\n                            // Need to go to the settings\n                            Toast.makeText(getApplicationContext(), \"Need to go to the settings\", Toast.LENGTH_SHORT).show();\n                        }\n                    }\n                });\n```\n\n3. Request permissions in asynchronous thread\n\n```java\nPermissionCompat.checkSelfPermissions(activity, new WeakRefSimpleCallback(activity), PERMISSIONS);\n```\n\n## Latest Changes\n- [Changelog.md](CHANGELOG.md)\n\nMore usage see [Demo](app/src/main/java/com/d/permissioncompat/MainActivity.java)\n\n## Licence\n\n```txt\nCopyright 2018 D\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsiner%2Fpermissioncompat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsiner%2Fpermissioncompat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsiner%2Fpermissioncompat/lists"}