Android6.0权限问题解析
程序员文章站
2022-08-11 09:57:21
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);
}