Android 多媒体资料中未显示视频
我已将视频保存在SD卡上,但它未显示在gallery中 我可以看到sd卡中的视频及其播放 我使用这个方法来获取视频uri并保存它Android 多媒体资料中未显示视频,android,Android,我已将视频保存在SD卡上,但它未显示在gallery中 我可以看到sd卡中的视频及其播放 我使用这个方法来获取视频uri并保存它 public static Uri getVideoUri(Context context) { Marapreferences marapreferences=Marapreferences.getInstance(context); boolean ismedia=marapreferences.isMedia();
public static Uri getVideoUri(Context context) {
Marapreferences marapreferences=Marapreferences.getInstance(context);
boolean ismedia=marapreferences.isMedia();
File file = null;
File file2 = new File(Environment.getExternalStorageDirectory()
+ "/mara_messenger/videos");
if (!file2.exists()) {
file2.mkdirs();
}
currentFileName = "" + System.currentTimeMillis() + ".mp4";
imageName = Environment.getExternalStorageDirectory()
+ "/mara_messenger/videos/" + currentFileName;
file = new File(imageName);
Uri imgUri = Uri.fromFile(file);
System.out.println("Image uri" + imgUri);
return imgUri;
}
File file=new File(uri);
MediaScannerConnection.scanFile(this, new String[] {file.getAbsolutePath()},
new String[]{"video/mp4"}, new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri)
{
System.out.println("completed");
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(uri);
sendBroadcast(intent);
}
});
我可以看到扫描后的URI和路径,但仍然没有显示在gallery上请确保通过告诉MediaScanner我正在处理的新文件来更新MediaStore s4它不在这里工作我甚至测试了S4I正在编辑我的答案以放置扫描代码