<分区>
在我的 android 应用程序中,我使用 Google 驱动器来选择图像和文件,对于文件,我的代码大部分时间都运行良好。不幸的是,在某些情况下图像导入不起作用,图像位图返回空值,下面是我用来将内容 URI 转换为输入流和位图的代码。
Bitmap bitmap = null;
InputStream input = null;
try {
input = getActivity()
.getContentResolver()
.openInputStream(
Uri.parse("content://com.google.android.apps.docs.storage/document/acc%3D2%3Bdoc%3D83"));
Log.Logger()
.finest("Profileimagefile Fragment Drive called input" + input);
bitmap = BitmapFactory
.decodeStream(input);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
我提到了无效的 URI,请帮助我找出问题。