作者:潇潇小姐姐cherryhv_309 | 来源:互联网 | 2023-02-02 13:05
请帮助我获取权限“ WRITE_EXTERNAL_STORAGE”和“ WRITE_SETTINGS”的请求代码。还请让我知道请求代码的来源。
1> 小智..:
一个简单的演示:
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(thisActivity,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
YourRequestCode);
}
您可以设置YourRequestCode
任何值,例如1
。