拍照后强制扫描文件 [英] Force scan files after taking photo

查看:321
本文介绍了拍照后强制扫描文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在API级别4(Android 1.6的),使用拍照后:

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);

我想仔细看看我的所有照片的缩略图,但没有我的最后一张照片缩略图。它完美的Andr​​oid 2.1系统。

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.

如果我通过USB连接设备到电脑,然后断开文件将出现,完成扫描后。所以,我应该如何开始的索引?

If I connect device via USB to PC and then disconnect file will appear, after finished scanning. So how should I start that indexing?

我试过

mScanner = new MediaScannerConnection(getApplicationContext(), this);
mScanner.connect();
mScanner.scanFile(imageUri.getEncodedPath(), "*/*");

和与这一目的:

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);

当我检查的第一个值计数我有13个元素,并在第二个我有14所以图像已被添加到mediascanner,但操作系统并没有产生缩略图它。所以,我应该怎么问操作系统创建一个?

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?

推荐答案

拍照尝试调用的<一插入()函数之后href="http://developer.android.com/reference/android/content/ContentResolver.html#insert%28android.net.Uri,%20android.content.ContentValues%29"相对=nofollow> ContentResolver的通过对图像信息。

after taking picture try calling insert() function of ContentResolver passing the information about the picture.

public final Uri insert (Uri url, ContentValues values)

这将画面实际添加到数据库中,并创建图片的缩略图适合你。它也将被添加至缩略图数据库。希望这有助于!

It will actually add the picture to the database and create picture's thumbnail image for you. It will also be added to the thumbnail database. Hope this helps!

这篇关于拍照后强制扫描文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆