Android图片保存到SD卡,未显示在Gallery中
目前,我有一个程序,可以拍摄照片并将其保存为SD卡顶层的jpg,但它不会出现在图库中。我必须做些什么才能让它发生吗?您需要这样做,以便它知道您的文件存在:Android图片保存到SD卡,未显示在Gallery中,android,android-camera,android-sdcard,Android,Android Camera,Android Sdcard,目前,我有一个程序,可以拍摄照片并将其保存为SD卡顶层的jpg,但它不会出现在图库中。我必须做些什么才能让它发生吗?您需要这样做,以便它知道您的文件存在: File file; // = your file String mimetype; // = your file's mimetype. MimeTypeMap may be useful. MediaScanner.scanFile(getApplicationContext(), new String[]{file.getPath()}
File file; // = your file
String mimetype; // = your file's mimetype. MimeTypeMap may be useful.
MediaScanner.scanFile(getApplicationContext(), new String[]{file.getPath()}, new String[]{mimetype}, null);
也许有人在“监督”它
看看:试试这个答案。为我工作
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(finalFile)));
请举例说明如何使用它?:)没关系,这里有。看在上帝的份上,什么是MediaScanner,它应该是
MediaScannerConnection
!它应该是这样的:MediaScannerConnection.scanFile(getContext(),新字符串[]{file.getPath()},null,null)代码>