我正在使用方法 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/