如何检查用户是否接受读/写联系人的权限?

时间:2022-06-15 13:18:46

my app read contacts from cell phone so when it run he get for permission.

我的应用程序从手机上读取联系人,所以当它运行时,他获得了许可。

How I ask again or check if the user gave permission?

我如何再次询问或检查用户是否允许?

Thank you very much.

非常感谢你。

1 个解决方案

#1


6  

User's don't really have the option to chose which permissions they approve or not. It's either they approve everything and your app installs, or they chose to decline and then your app doesn't install.

用户实际上没有选择他们批准或不批准的权限。要么他们批准了所有内容并且您的应用安装了,要么他们选择拒绝,然后您的应用无法安装。

However, to answer your question you can use the checkPermission method in the PackageManager

但是,要回答您的问题,您可以使用PackageManager中的checkPermission方法

PackageManager manager = getPackageManager();
int hasPermission = manager.checkPermission ("android.permission.READ_CONTACTS", "com.your.package")
if (hasPermission == manager.PERMISSION_GRANTED) {
    //you have permission
}

#1


6  

User's don't really have the option to chose which permissions they approve or not. It's either they approve everything and your app installs, or they chose to decline and then your app doesn't install.

用户实际上没有选择他们批准或不批准的权限。要么他们批准了所有内容并且您的应用安装了,要么他们选择拒绝,然后您的应用无法安装。

However, to answer your question you can use the checkPermission method in the PackageManager

但是,要回答您的问题,您可以使用PackageManager中的checkPermission方法

PackageManager manager = getPackageManager();
int hasPermission = manager.checkPermission ("android.permission.READ_CONTACTS", "com.your.package")
if (hasPermission == manager.PERMISSION_GRANTED) {
    //you have permission
}