Android6.0权限问题解析
程序员文章站
2022-04-19 21:32:45
android6.0权限问题解析。
//申请权限
private void createdownloadpression() {
int result = activityc...
android6.0权限问题解析。
//申请权限
private void createdownloadpression() {
int result = activitycompat.checkselfpermission(this, manifest.permission.write_external_storage);
if (result == packagemanager.permission_denied){
activitycompat.requestpermissions(this,new string[]{manifest.permission.write_external_storage},0);
}
}
//回调
@override
public void onrequestpermissionsresult(int requestcode, @nonnull string[] permissions, @nonnull int[] grantresults) {
if (grantresults[0] == packagemanager.permission_granted){
downloadmanage.getinstance().createdownloaddir();//创建下载目
}else {
toast.maketext(this,”没有权限”,toast.length_long).show();
}
super.onrequestpermissionsresult(requestcode, permissions, grantresults);
}
上一篇: jdk8新功能