2014-04-01 59 views
6

不显示我启动默认相机使用意图和存储使用以下路径外部存储那些相机图像:形象画廊

File file = new File(Environment.getExternalStorageDirectory() 
        + File.separator + fileName); 

不过,这并不在画廊展示。这个问题进来的Nexus 4,7和摩托g设备与OS 4.4.2

我尝试用

mContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri 
       .parse("file://" + Environment.getExternalStorageDirectory()))); 

,但它不能正常工作

+1

您需要致电MediaScanner,请查看:http://stackoverflow.com/a/5815005/2065418 –

回答

1

你必须刷新媒体扫描仪的缓存,尝试这:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(yourFile))); 
0

你必须告诉设备扫描新的媒体文件。试试这个片段:

MediaScannerConnection.scanFile(
     this, new String[]{file.getAbsolutePath()}, null, null); 
0

我想你最好在相机的默认文件夹中创建一个文件夹,并将其中的数据。检查名称为“.nomedia”的文件是否不在该文件夹中。