本文介绍了得到采取用户的最后一张照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,我想通过任何摄像头的应用程序捕获用户的最后一张照片。我不知道该怎么做。
任何一个可以帮助我吗?
另外我想发送的图像作为附件的电子邮件或彩信..
感谢
解决方案
//找到最后一张图片
的String []投影=新的String [] {
MediaStore.Images.ImageColumns._ID,
MediaStore.Images.ImageColumns.DATA,
MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME,
MediaStore.Images.ImageColumns.DATE_TAKEN,
MediaStore.Images.ImageColumns.MIME_TYPE
};
最后光标光标= getContentResolver()
.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,投影,空,
空,MediaStore.Images.ImageColumns.DATE_TAKEN +降序);
//把它放在图像视图
如果(cursor.moveToFirst()){
最后的ImageView ImageView的=(ImageView的)findViewById(R.id.pictureView);
串imageLocation = cursor.getString(1);
文件镜像文件=新的文件(imageLocation);
如果(imageFile.exists()){// TODO:有没有更好的办法做到这一点?
位图BM = BitmapFactory.de codeFILE(imageLocation);
imageView.setImageBitmap(BM);
}
}
我还在努力的一部分发送彩信。
hey I want to get the last picture captured by user through any camera application.I have no idea how to do that
can any one help me?
further I want to send that image as an attachment to an email or MMS..
thanks
解决方案
// Find the last picture
String[] projection = new String[]{
MediaStore.Images.ImageColumns._ID,
MediaStore.Images.ImageColumns.DATA,
MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME,
MediaStore.Images.ImageColumns.DATE_TAKEN,
MediaStore.Images.ImageColumns.MIME_TYPE
};
final Cursor cursor = getContentResolver()
.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null,
null, MediaStore.Images.ImageColumns.DATE_TAKEN + " DESC");
// Put it in the image view
if (cursor.moveToFirst()) {
final ImageView imageView = (ImageView) findViewById(R.id.pictureView);
String imageLocation = cursor.getString(1);
File imageFile = new File(imageLocation);
if (imageFile.exists()) { // TODO: is there a better way to do this?
Bitmap bm = BitmapFactory.decodeFile(imageLocation);
imageView.setImageBitmap(bm);
}
}
I'm still working on the MMS sending part.
这篇关于得到采取用户的最后一张照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!