發現程式把圖檔儲存到sdcard後,在相冊裡面找不到,隻有在sdcard重新裝載後會出現圖檔;
原來圖檔儲存到本地後,需要通知相冊,加上如下代碼就好了:
Uri localUri = Uri.fromFile(imageFile);
Intent localIntent = new
Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, localUri);
sendBroadcast(localIntent);
imageFile是圖檔的File對象;
或者
ContentValues localContentValues = new ContentValues();
localContentValues.put("_data", imageFile.toString());
localContentValues.put("description", "save image ---");
localContentValues.put("mime_type", "image/jpeg");
ContentResolver localContentResolver = getContentResolver();
Uri localUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
localContentResolver.insert(localUri, localContentValues);