保存捕获图像在SD卡机器人 [英] Save Capture Image in SD card android

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

问题描述

我把相机意图,并尝试保存捕捉图像SD card.but相机意图给我空data.what的问题是我不能understood.my code是如下

I call camera intent and try to save capture image in sd card.but camera intent give me null data.what is the problem i can't understood.my code is as follow

imgBtnPicture.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            String fileName="ashraful.jpg";

            String root = Environment.getExternalStorageDirectory().toString();
            new File(root + "/photofolder").mkdirs();
            File outputfile=new File(root+"/photofolder/", fileName);
            Uri outputFileUri = Uri.fromFile(outputfile);
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            startActivityForResult(cameraIntent, CAMERA_REQUEST); 
        }
    }); 


protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data); 
    if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) { 

        if(data!=null)
        {
            Bitmap photo = (Bitmap) data.getExtras().get("data");
            Bitmap icon1=ResizeBitmap(photo,200,200);
            imgBtnPicture.setImageBitmap(icon1);
        }
    }  
}

但我得到空数据?如何解决我的问题?plz帮助

but i get null data? how to solve my problem?plz help

推荐答案

这个 Android的培训仔细张贴理出头绪。正如帖子里说,

Read this Android Training post carefully to figure things out. As the post says,

Android相机应用程序保存一个全尺寸的照片,如果你给它一个文件保存到。

The Android Camera application saves a full-size photo if you give it a file to save into.

所以,如果你是传递一个文件的乌里,你应该使用访问这个图片的乌里

so if you did pass the Uri of a file, you should access the image using this Uri.

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

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