on api level 4 (android 1.6), after taking photo using:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File(Environment.getExternalStorageDirectory(), "NewPic.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
imageUri = Uri.fromFile(photo);
startActivityForResult(intent, TAKE_PICTURE);
I'd like to look through all my photos thumbnails, but there is no my last photo thumbnail. It works perfectly on android 2.1.
If I connect device via USB to PC and then disconnect file will appear, after finished scanning. So how should I start that indexing?
I tried
mScanner = new MediaScannerConnection(getApplicationContext(), this);
mScanner.connect();
mScanner.scanFile(imageUri.getEncodedPath(), "*/*");
And end with this:
02-24 17:13:54.678: DEBUG/MediaScannerService(1320): IMediaScannerService.scanFile: /sdcard/NewPic2222.jpg mimeType: */*
02-24 17:13:54.688: VERBOSE/MediaProvider(1320): /sdcard volume ID: 1149784819
02-24 17:13:54.688: VERBOSE/MediaProvider(1320): key exists
EDITED LATER
I've got sth like this in other activity
mCursorThumbnails = MediaStore.Images.Thumbnails.queryMiniThumbnails(mContentResolver, MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, MediaStore.Images.Thumbnails.MINI_KIND, projection);
mCursorImages = MediaStore.Images.Media.query(mContentResolver, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection);
When I check count of first value I've got 13 elements, and on the second I've got 14. So the image has been added to mediascanner, but OS hasn't generated thumbnail for it. So how should I ask OS to create one?
Whenever you add a file, let MediaStore Content Provider knows about it using the sendBroadcast method
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(mediaFileAdded)));
For deletion, use:
getContentResolver().delete(uriOfMediaFileDeteled, null, null)
Main advantage: work with any mime type supported by MediaStore
In your case, do this in onActivityResultMethod (i.e.) after the photo has been successfuly taken