[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4115":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":21,"defaultBranch":22,"hasWiki":20,"hasPages":21,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":30,"lastSyncTime":31,"discoverSource":32},4115,"easypermissions","googlesamples\u002Feasypermissions","googlesamples","Simplify Android M system permissions","https:\u002F\u002Ffirebaseopensource.com\u002Fprojects\u002Fgooglesamples\u002Feasypermissions\u002F",null,"Java",9866,1459,1,36,0,4,40.49,"Apache License 2.0",true,false,"master",[24,25,26],"android","android-library","permissions","2026-06-12 02:00:58","# EasyPermissions [![Build Status][1]][2] [![Android Weekly][3]][4]\n\nEasyPermissions is a wrapper library to simplify basic system permissions logic when targeting\nAndroid M or higher.\n\n**Note:** If your app is written in Kotlin consider the [easypermissions-ktx](https:\u002F\u002Fgithub.com\u002FVMadalin\u002Feasypermissions-ktx)\nlibrary which adds Kotlin extensions to the core EasyPermissions library.\n\n## Installation\n\nEasyPermissions is installed by adding the following dependency to your `build.gradle` file:\n\n```groovy\ndependencies {\n    \u002F\u002F For developers using AndroidX in their applications\n    implementation 'pub.devrel:easypermissions:3.0.0'\n \n    \u002F\u002F For developers using the Android Support Library\n    implementation 'pub.devrel:easypermissions:2.0.1'\n}\n```\n\n## Usage\n\n### Basic\n\nTo begin using EasyPermissions, have your `Activity` (or `Fragment`) override the `onRequestPermissionsResult` method:\n\n```java\npublic class MainActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n    }\n\n    @Override\n    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {\n        super.onRequestPermissionsResult(requestCode, permissions, grantResults);\n\n        \u002F\u002F Forward results to EasyPermissions\n        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);\n    }\n}\n```\n\n### Request Permissions\n\nThe example below shows how to request permissions for a method that requires both\n`CAMERA` and `ACCESS_FINE_LOCATION` permissions. There are a few things to note:\n\n  * Using `EasyPermissions#hasPermissions(...)` to check if the app already has the\n    required permissions. This method can take any number of permissions as its final\n    argument.\n  * Requesting permissions with `EasyPermissions#requestPermissions`. This method\n    will request the system permissions and show the rationale string provided if\n    necessary. The request code provided should be unique to this request, and the method\n    can take any number of permissions as its final argument.\n  * Use of the `AfterPermissionGranted` annotation. This is optional, but provided for\n    convenience. If all of the permissions in a given request are granted, *all* methods\n    annotated with the proper request code will be executed(be sure to have an unique request code). The annotated method needs to be *void* and *without input parameters* (instead, you can use *onSaveInstanceState* in order to keep the state of your suppressed parameters). This is to simplify the common\n    flow of needing to run the requesting method after all of its permissions have been granted.\n    This can also be achieved by adding logic on the `onPermissionsGranted` callback.\n\n```java\n@AfterPermissionGranted(RC_CAMERA_AND_LOCATION)\nprivate void methodRequiresTwoPermission() {\n    String[] perms = {Manifest.permission.CAMERA, Manifest.permission.ACCESS_FINE_LOCATION};\n    if (EasyPermissions.hasPermissions(this, perms)) {\n        \u002F\u002F Already have permission, do the thing\n        \u002F\u002F ...\n    } else {\n        \u002F\u002F Do not have permissions, request them now\n        EasyPermissions.requestPermissions(this, getString(R.string.camera_and_location_rationale),\n                RC_CAMERA_AND_LOCATION, perms);\n    }\n}\n```\n\nOr for finer control over the rationale dialog, use a `PermissionRequest`:\n\n```java\nEasyPermissions.requestPermissions(\n        new PermissionRequest.Builder(this, RC_CAMERA_AND_LOCATION, perms)\n                .setRationale(R.string.camera_and_location_rationale)\n                .setPositiveButtonText(R.string.rationale_ask_ok)\n                .setNegativeButtonText(R.string.rationale_ask_cancel)\n                .setTheme(R.style.my_fancy_style)\n                .build());\n```\n\nOptionally, for a finer control, you can have your `Activity` \u002F `Fragment` implement\nthe `PermissionCallbacks` interface.\n\n```java\npublic class MainActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n    }\n\n    @Override\n    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {\n        super.onRequestPermissionsResult(requestCode, permissions, grantResults);\n\n        \u002F\u002F Forward results to EasyPermissions\n        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);\n    }\n\n    @Override\n    public void onPermissionsGranted(int requestCode, List\u003CString> list) {\n        \u002F\u002F Some permissions have been granted\n        \u002F\u002F ...\n    }\n\n    @Override\n    public void onPermissionsDenied(int requestCode, List\u003CString> list) {\n        \u002F\u002F Some permissions have been denied\n        \u002F\u002F ...\n    }\n}\n```\n\n### Required Permissions\n\nIn some cases your app will not function properly without certain permissions. If the user\ndenies these permissions with the \"Never Ask Again\" option, you will be unable to request\nthese permissions from the user and they must be changed in app settings. You can use the\nmethod `EasyPermissions.somePermissionPermanentlyDenied(...)` to display a dialog to the\nuser in this situation and direct them to the system setting screen for your app:\n\n**Note**: Due to a limitation in the information provided by the Android\nframework permissions API, the `somePermissionPermanentlyDenied` method only\nworks after the permission has been denied and your app has received\nthe `onPermissionsDenied` callback. Otherwise the library cannot distinguish\npermanent denial from the \"not yet denied\" case.\n\n```java\n@Override\npublic void onPermissionsDenied(int requestCode, List\u003CString> perms) {\n    Log.d(TAG, \"onPermissionsDenied:\" + requestCode + \":\" + perms.size());\n\n    \u002F\u002F (Optional) Check whether the user denied any permissions and checked \"NEVER ASK AGAIN.\"\n    \u002F\u002F This will display a dialog directing them to enable the permission in app settings.\n    if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {\n        new AppSettingsDialog.Builder(this).build().show();\n    }\n}\n\n@Override\npublic void onActivityResult(int requestCode, int resultCode, Intent data) {\n    super.onActivityResult(requestCode, resultCode, data);\n\n    if (requestCode == AppSettingsDialog.DEFAULT_SETTINGS_REQ_CODE) {\n        \u002F\u002F Do something after user returned from app settings screen, like showing a Toast.\n        Toast.makeText(this, R.string.returned_from_app_settings_to_activity, Toast.LENGTH_SHORT)\n                .show();\n    }\n}\n```\n\n### Interacting with the rationale dialog\n\nImplement the `EasyPermissions.RationaleCallbacks` if you want to interact with the rationale dialog.\n\n```java\n@Override\npublic void onRationaleAccepted(int requestCode) {\n    \u002F\u002F Rationale accepted to request some permissions\n    \u002F\u002F ...\n}\n\n@Override\npublic void onRationaleDenied(int requestCode) {\n    \u002F\u002F Rationale denied to request some permissions\n    \u002F\u002F ...\n}\n```\n\nRationale callbacks don't necessarily imply permission changes. To check for those, see the `EasyPermissions.PermissionCallbacks`.\n\n## LICENSE\n\n```\n\tCopyright 2017 Google\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n     http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n```\n\n[1]: https:\u002F\u002Fgithub.com\u002Fgooglesamples\u002Feasypermissions\u002Fworkflows\u002Ftest\u002Fbadge.svg\n[2]: https:\u002F\u002Fgithub.com\u002Fgooglesamples\u002Feasypermissions\u002Factions\n[3]: https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FAndroid%20Weekly-%23185-2CB3E5.svg?style=flat\n[4]: http:\u002F\u002Fandroidweekly.net\u002Fissues\u002Fissue-185\n","EasyPermissions 是一个简化 Android M 或更高版本系统权限处理的库。它通过提供简洁的API来检查、请求和处理权限结果，使得开发者可以更方便地管理应用中的权限逻辑，支持AndroidX和Android Support Library两种依赖方式。该库特别适合需要处理运行时权限但又希望减少代码复杂性的Android应用程序开发场景。使用EasyPermissions可以让权限请求流程更加直观且易于维护，同时其提供的Kotlin扩展库进一步增强了对Kotlin语言的支持。",2,"2026-06-11 02:58:32","top_language"]