gpt4 book ai didi

android - 运行应用程序时找不到 EasyPermissions 库错误?

转载 作者:行者123 更新时间:2023-11-30 05:01:48 24 4
gpt4 key购买 nike

我在我的项目中使用 EasyPermissions 库。它构建成功但在运行时出错。我正在 28 年构建我的应用程序。我使用最新版本和之前的版本,但仍然遇到相同的错误。

最佳答案

I recommended to use below Android Run time Permission Library

实现'com.nabinbhandari.android:permissions:3.8'

首先在 list 中声明您的权限。

喜欢

示例代码:1)单一权限()

Permissions.check(this, Manifest.permission.CALL_PHONE, null, new PermissionHandler() {
@Override
public void onGranted() {
// do your task.
}
});

2)多重权限:

String[] permissions = {Manifest.permission.CAMERA, 
Manifest.permission.WRITE_EXTERNAL_STORAGE};

Permissions.check(this/*context*/, permissions, null/*rationale*/, null/*options*/,
new PermissionHandler() {
@Override
public void onGranted() {
// do your task.
}
});

3)自定义权限请求:

String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION};
String rationale = "Please provide location permission so that you can ...";
Permissions.Options options = new Permissions.Options()
.setRationaleDialogTitle("Info")
.setSettingsDialogTitle("Warning");

Permissions.check(this/*context*/, permissions, rationale, options, new
PermissionHandler() {
@Override
public void onGranted() {
// do your task.
}

@Override
public void onDenied(Context context, ArrayList<String> deniedPermissions) {
// permission denied, block the feature.
}
});

Check this library: @github https://github.com/nabinbhandari/Android-Permissions

或检查此答案以获取权限代码 https://stackoverflow.com/a/55452495/10758304

关于android - 运行应用程序时找不到 EasyPermissions 库错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58114895/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com