如何从一个活动图像发送到另一个机器人? [英] How to send image from one activity to another in android?

查看:123
本文介绍了如何从一个活动图像发送到另一个机器人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一类和点击ImageView的一个对话框,显示它有两个选项,拍摄的图像从相机或打开设备的图像库中的ImageView的。我想从一个类发送图像到另一个,因此它可以出现在ImageView的。我从多小时寻找,但我只拿到大约从一个类发送文本数据another.Can任何一个讲述发送图像从一类到另一个?

I am having a imageView in one class and on clicking the imageView a dialog box appear which has two option to take a image from camera or open the image gallery of device. I want to send image from one class to another so it can appear in ImageView. I am searching from many hour but i got only about sending text data from one class to another.Can any one tell about sending an image from one class to another?

这是从发送方类code将于形象。

This is code from sender class which will take image.

   takeImg.setOnTouchListener(new OnTouchListener() {

            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                if(event.getAction() == event.ACTION_UP)
                {
                    i=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                    startActivityForResult(i,cameraData);
                }
                return true;
            }
        });
    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode==RESULT_OK)
        {
            Bundle extras=data.getExtras();
            bmp=(Bitmap)extras.get("data");
        }
    }

有关任何帮助的感谢

推荐答案

我把你需要发送图像的路径从一个活动到另一个答案。 filepath是图片的路径。

I got the answer you need to send path of image from one activity to another. filePath is the path of image.

Intent open_displayPage=new Intent(MainActivity.this,display_page.class);
open_displayPage.putExtra("imagePath", filePath);

和获取路径的另一个活动

And get the path in another activity

final String path = getIntent().getStringExtra("imagePath");
org_bmp = BitmapFactory.decodeFile(path);

这篇关于如何从一个活动图像发送到另一个机器人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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