如何保存捕捉图像中的SD卡? [英] how to save capture image in sdcard?

查看:127
本文介绍了如何保存捕捉图像中的SD卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用默认的摄像头和捕捉图像。我想保存的图像在SD卡/ photofolder /和保存的文件名如SD卡curenttime格式/ photofolder /还显示ImageView的页面捕获映像

I want to use default camera and capture image. i want save image in sdcard/photofolder/ and save filename as curenttime format in sdcard/photofolder/ also display capture image in imageview page

Uri outputFileUri = Uri.fromFile("/sdcard/Photofolder/");    
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, CAMERA_REQUEST);

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
            if (requestCode == CAMERA_REQUEST) {  
                Bitmap photo = (Bitmap) data.getExtras().get("data"); 
               // imageView.setImageBitmap(photo);

                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inSampleSize = 4;
                Bitmap bitmap = BitmapFactory.decodeFile(picFileName, options);
                imageView.setImageBitmap(bitmap);
                imageView.setVisibility(View.VISIBLE);

            }  
        }

这方面有任何想法?感谢adavance

any idea about this ?? thanks in adavance

推荐答案

SD卡路径得到这样的..

sdcard path get like..

串根= Environment.getExternalStorageDirectory()的toString();

String root = Environment.getExternalStorageDirectory().toString();

新的文件(根+/ photofolder)mkdirs();

new File(root + "/photofolder").mkdirs();

然后就可以将文件保存到根+/photofolder/20120830025700.jpg。

Then you can save a file to root + "/photofolder/20120830025700.jpg".

你有没有要求的权限写入到SD卡上?添加下面的字​​符串为您的应用程序清单:

Have you requested permission to write onto SD card? Add the following string to you app manifest:

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

这篇关于如何保存捕捉图像中的SD卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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