Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android Q上的刷新库_Java_Android_Android Mediascanner_Android 10.0 - Fatal编程技术网

Java Android Q上的刷新库

Java Android Q上的刷新库,java,android,android-mediascanner,android-10.0,Java,Android,Android Mediascanner,Android 10.0,使用getExternalFilesDir将视频保存到内部存储后,如果我从菜单(显示内部存储)转到文件资源管理器应用程序>视频>,我就能找到它: 但我在画廊里找不到它 创建路径: private void getPath() { String videoFileName = "vidoe_" + System.currentTimeMillis() + ".mp4"; if (Build.VERSION.SDK_INT >= Build.VERSION_C

使用
getExternalFilesDir
将视频保存到内部存储后,如果我从菜单(显示内部存储)转到文件资源管理器应用程序>视频>,我就能找到它:

但我在画廊里找不到它

创建路径:

private void getPath() {
        String videoFileName = "vidoe_" + System.currentTimeMillis() + ".mp4";
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            File imageFile = null;
            File storageDir = new File(getExternalFilesDir(Environment.DIRECTORY_MOVIES),
                    "folder");
            boolean success = true;
            if (!storageDir.exists()) {
                success = storageDir.mkdirs();
            }
            if (success) {
                imageFile = new File(storageDir, videoFileName);
                savedVideoPath = imageFile.getAbsolutePath();
            }

        } else {
            File storageDir = new File(
                    Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
                            + "/folder");
            boolean success = true;
            if (!storageDir.exists()) {
                success = storageDir.mkdirs();
            }
            if (success) {
                File videoFile = new File(storageDir, videoFileName);
                savedVideoPath = videoFile.getAbsolutePath();
            }
        }
    }
刷新库:

 private void galleryRefresh(String savedVideoPath) {
        Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
        File f = new File(savedVideoPath);
        Uri contentUri = Uri.fromFile(f);
        mediaScanIntent.setData(contentUri);
        sendBroadcast(mediaScanIntent);
    }