use*_*901 15 android google-drive-api
如果有人可以提供帮助,我会非常棒.我正在构建一个应用程序,我试图访问我的文件并在imageview中显示它们.
我有一个按钮,并附上一个onClickListener
iButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("image/*");
startActivityForResult(Intent.createChooser(photoPickerIntent, "Select Picture"), 1);
}
});
Run Code Online (Sandbox Code Playgroud)
意图为我提供了3个选项Gallery,Dropbox和Google Drive
对于Gallery我可以访问文件lis this并将其显示在imageview中
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
imageHolder.setImageBitmap(BitmapFactory.decodeFile(picturePath));
Run Code Online (Sandbox Code Playgroud)
对于Dropbox,我这样做
imageHolder.setImageBitmap(BitmapFactory.decodeFile(selectedImage.getPath()));
Run Code Online (Sandbox Code Playgroud)
但是我不确定如何为谷歌驱动器做它我试图像画廊一样,但我得到以下错误
E/BitmapFactory:无法解码流:java.io.FileNotFoundException:/:open failed:EISDIR(是一个目录)
任何帮助将非常感激.
| 归档时间: |
|
| 查看次数: |
10880 次 |
| 最近记录: |