以下のように Uri.getPath() includes /-1/1/ を取得する際に問題が発生しました。
protected void onActivityResult(int reqCode, int resultCode, Intent data)
次のように PICK Multiple Images から
ClipData.Item item = clipData.getItemAt(i);
Uri uri = item.getUri();
Uri からファイルを取得しようとしましたが、次のサンプル コードでは常にエラーが発生します: FileNotFound
private void getImg(Uri uri){
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(new File(uri.getPath()).getAbsolutePath(), options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
/....... some code ...
// ArrayList<File>
mFile.add(new File(uri.getPath());
}
06-29 12:33:34.829 8160-8160/com.jinn.mutita.photoImx E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException:
/-1/1/content:/media/external/images/media/15878/ORIGINAL/NONE/3385104: open failed: ENOENT (No such file or directory)
ただし、次のようにしてローカルファイルに保存すると、実行できます。
InputStream input = thiscontext.getContentResolver().openInputStream(uri);
しかし、最初に安全な入力ストリームをローカルで行うことができます。助けてください。すでに検索していますが、Uri 形式が変更されたかどうかはわかりません。
Uri からのパスを持つファイルを処理するには? . ありがとう