android如何将捕获的图像保存到手机库中

【android如何将捕获的图像保存到手机库中】不飞则已,一飞冲天;不鸣则已,一鸣惊人。这篇文章主要讲述android如何将捕获的图像保存到手机库中相关的知识,希望能为你提供帮助。
我有两个活动。在一项活动中,我有一个ImageView和一个相机按钮。当我按下相机按钮时,它会转到其他活动,其中两个按钮在那里捕获,另一个是选择按钮。按下捕获时,它会捕获图像。但问题是如何将此捕获图像保存到图库。按下“选择”按钮后,捕获的图像应显示在第1个活动的ImageView上。我怎样才能做到这一点。
答案请参阅http://blog.kupriyanov.com/2010/02/solved-android-save-image-to-media.html以保存到图库,并查看Get/pick an image from Android's built-in Gallery app programmatically以显示图库图像。
另一答案这就是我做的方式。图像在SDCard上以分钟+秒+ .jpg保存:

final static private int NEW_PICTURE = 1; private String mCameraFileName; ImageButton Edit = (ImageButton) findViewById(R.id.internetbrowser4); Edit.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); // Picture from camera intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); // This is not the right way to do this, but for some reason, having // it store it in // MediaStore.Images.Media.EXTERNAL_CONTENT_URI isn't working right.Date date = new Date(); DateFormat df = new SimpleDateFormat("-mm-ss"); String newPicFile = "Bild"+ df.format(date) + ".jpg"; String outPath = "/sdcard/" + newPicFile; File outFile = new File(outPath); mCameraFileName = outFile.toString(); Uri outuri = Uri.fromFile(outFile); intent.putExtra(MediaStore.EXTRA_OUTPUT, outuri); startActivityForResult(intent, NEW_PICTURE); } }); public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == NEW_PICTURE) { // return from file upload if (resultCode == Activity.RESULT_OK) { Uri uri = null; if (data != null) { uri = data.getData(); } if (uri == null & & mCameraFileName != null) { uri = Uri.fromFile(new File(mCameraFileName)); } File file = new File(mCameraFileName); if (!file.exists()) { file.mkdir(); } } }} }

另一答案试试这个..
String path = Environment.getExternalStorageDirectory() + "/CameraImages/example.jpg"; File file = new File(path); Uri outputFileUri = Uri.fromFile( file ); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE ); intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri ); startActivityForResult( intent, CAPTURE_IMAGE );

您的图像将保存在此位置“sdcard / CameraImages / example.jpg”

    推荐阅读