📜  android studio permission_granted - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:33.535000             🧑  作者: Mango

代码示例1
if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
     ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},0);
     
//explaination of if code:if the MainActivity you are currently on does not have a granted permission of
//reading external storage then MainActivity will request premission for
//reading external storage **must add to manifiest the Read_external_Storage permission
//for the permission to appear