最近项目上有个需求,读取通讯录。当用户点了拒绝访问通讯录或者其他权限,导致无法使用,这时候我想重新打开权限设置,但是对于很多小白用户不知道怎么设置,这就会导致用户体验不友好的一面。
之前已经有人写过类似的文章,不过都比较分散,经实测将这些方法总结了一下。
要跳转的权限设置界面如图:目前手上只有华为和小米作为测试
MIUI:
华为:
上代码前先整理下关于Build类的相关调用,后面有可能用到:
在官方文档中可以查到Build类中有如下常量:
public static final String | BOARD | The name of the underlying board, like "goldfish".主板名称 |
public static final String | BOOTLOADER | The system bootloader version number.系统引导程序版本号 |
public static final String | BRAND | The brand (e.g., carrier) the software is customized for, if any.android系统定制商 |
public static final String | CPU_ABI | The name of the instruction set (CPU type + ABI convention) of native code.CPU 和ABI的本地代码指令集 |
public static final String | CPU_ABI2 | The name of the second instruction set (CPU type + ABI convention) of native code. |
public static final String | DEVICE | The name of the industrial design.设备参数 |
public static final String | DISPLAY | A build ID string meant for displaying to the user显示屏参数 |
public static final String | FINGERPRINT | A string that uniquely identifies this build.硬件名 |
public static final String | HARDWARE | The name of the hardware (from the kernel command line or /proc).内核命令行中的硬件名 |
public static final String | HOST | |
public static final String | ID | Either a changelist number, or a label like "M4-rc20".修改版本列表 |
public static final String | MANUFACTURER | The manufacturer of the product/hardware.硬件厂商 |
public static final String | MODEL | The end-user-visible name for the end product.版本 |
public static final String | PRODUCT | The name of the overall product.手机厂商 |
public static final String | RADIO |
This field was deprecated in API level 14. The radio firmware version is frequently not available when this class is initialized, leading to a blank or "unknown" value for this string. UsegetRadioVersion() instead. |
public static final String | SERIAL |
A hardware serial number, if available. |
public static final String | TAGS |
Comma-separated tags describing the build, like "unsigned,debug".描述Build的标签 |
public static final long | TIME |
|
public static final String | TYPE |
The type of build, like "user" or "eng".Build的类型 |
public static final String | USER |
|