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);
}