誰かが私を助けることができれば、私は本当に素晴らしいでしょう. ファイルにアクセスしてイメージビューに表示しようとしているアプリを構築しています。
ボタンがあり、それに 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);
}
});
このインテントには、ギャラリー、Dropbox、Google ドライブの 3 つのオプションがあります。
ギャラリーの場合、ファイル lis this にアクセスしてイメージビューに表示できます
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));
Dropboxの場合、私はこのようにします
imageHolder.setImageBitmap(BitmapFactory.decodeFile(selectedImage.getPath()));
ただし、Googleドライブでそれを行う方法がわからないため、ギャラリーのように実行しようとしましたが、次のエラーが表示されます
E/BitmapFactory: ストリームをデコードできません: java.io.FileNotFoundException: /: オープンに失敗しました: EISDIR (ディレクトリです)
どんな助けでも大歓迎です。