gpt4 book ai didi

android - Android 6.0如何获取runtimepermission

转载 作者:行者123 更新时间:2023-11-30 01:17:52 26 4
gpt4 key购买 nike

我正在使用方法 YouTubeIntents.createUploadIntent 并得到下面的异常,

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.youtube/com.google.android.apps.youtube.app.honeycomb.Shell$UploadActivity}: java.lang.SecurityException: Uid 10075 does not have permission to uri 0 @ content://media/external/video/media/7757

此异常表示 youtube 应用程序没有权限 READ_EXTERNAL_STORAGE。

如何处理这个异常?

最佳答案

这就是你应该做的。

 if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.READ_EXTERNAL_STORAGE) {

// Should we show an explanation?
if (shouldShowRequestPermissionRationale(
Manifest.permission.READ_EXTERNAL_STORAGE)) {
// Explain to the user why we need to read the contacts
}

requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);

// MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE is an
// app-defined int constant

return;
}

在此处找到代码 fragment :https://developer.android.com/preview/features/runtime-permissions.html

关于android - Android 6.0如何获取runtimepermission,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37582409/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com