大佬教程收集整理的这篇文章主要介绍了android – 从我的应用程序使用Intent打开相机时停止保存图像,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
大家好,
我就像这样使用Intent打开相机
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent,ACTIVITY_CAMERA);
它很好,并给我结果完美,但问题是这将把图像保存到SD卡,如何防止这停止保存图像,只是将该数据用于onActivityResult()方法
onActivityResult我正在拍摄Image,然后将其存储到另一个位图中.
看到这个:
if(resultCode == RESULT_OK && requestCode==TAKE_PHOTO_CODE){ final File file = getTempFile(this); try { tempBitmap = Media.getBitmap(getContentResolver(),Uri.fromFile(filE)); photoBitmap = Bitmap.createScaledBitmap(tempBitmap,display.getWidth(),display.getHeight(),truE); takePhotoFromCamera = true; // do whatever you want with the bitmap (Resize,Rename,Add To Gallery,etC) } catch (FileNotFoundException E) { e.printStackTrace(); } catch (IOException E) { e.printStackTrace(); } }
现在,您可以在将文件带到位图后删除该文件.所以它可能没有保存到SD卡.
试试吧.希望它会对你有所帮助.
要么 . . .
用这个:
String[] projection = new String[] {MediaStore.Images.Imagecolumns._ID,MediaStore.Images.Imagecolumns.DATA,MediaStore.Images.Imagecolumns.bUCKET_DISPLAY_NAME,DATE_TAKEN,MediaStore.Images.Imagecolumns.MIME_TYPE}; final cursor cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,projection,null,DATE_TAKEN + " DESC");
请享用. :))
以上是大佬教程为你收集整理的android – 从我的应用程序使用Intent打开相机时停止保存图像全部内容,希望文章能够帮你解决android – 从我的应用程序使用Intent打开相机时停止保存图像所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。