0

デバイスで新しい写真をリッスンし、サイズを変更してクラウドにアップロードするアプリケーションがあります。

写真の間に小さな一時停止(たとえば1秒)を入れて写真を撮っている場合はすべて問題ありませんが、一時停止せずに写真をすばやく撮っている場合は例外があります:

java.io.FileNotFoundException: /storage/emulated/0/DCIM/Camera/IMG_20180116_150824_1.jpg (No such file or directory)

私のcompressAndResize関数で。

その関数では、次のようなことをしています:

 private static File compressAndResizeImage(File sourceFile, File destination) throws IOException {

    File compressedAssetFile = new File(destination, sourceFile.getName());

    if (!compressedAssetFile.getParentFile().exists()) {
        //noinspection ResultOfMethodCallIgnored
        compressedAssetFile.getParentFile().mkdirs();
    }
    //noinspection ResultOfMethodCallIgnored
    compressedAssetFile.getParentFile().createNewFile();

    FileOutputStream fileOutputStream = null;

    int width;
    int height;

    try {
        fileOutputStream = new FileOutputStream(compressedAssetFile);

        Bitmap source = BitmapFactory.decodeFile(sourceFile.getAbsolutePath());

        int sourceWidth = source.getWidth();
        int sourceHeight = source.getHeight();
...

BitmapFactory.decodeFileメソッドで例外がスローされます。

写真を急いでいるときになぜそのような行動が起こるのか、私にはわかりません。

誰かが私の理由を説明できますか?

前もって感謝します!

4

0 に答える 0