0

I have tried this code. where is the wrong?

In 1st activity:

Cursor cursor = dbhelper.getdata(Adapter.KEY_RID, _id);
Intent intent = new Intent(this, SecondActivity.class);
   intent.putExtra("image",getImage(d.getBlob(d.getColumnIndex(DbAdapter.KEY_IMG))));
//intent.putExtra("image",d.getBlob(d.getColumnIndex(DbAdapter.KEY_IMG)));

in second activity:

ImageView iv = (ImageView) findViewById(R.id.img);
iv.setImageBitmap(getIntent().getStringExtra("image"));
//iv.setImageBitmap(getImage(getIntent().getStringExtra("image")));

and get Image:

 public static Bitmap getImage(byte[] image) {
        return BitmapFactory.decodeByteArray(image, 0, image.length);
    }
dll
  • 61
  • 5

1 Answers1

0

Pass image path in your Intent as intent.putExtra("ImagePath","YOUR_IMAGE_PATH_OR_URL"); to the next activity. Then get the image path on next activity like getIntent().getStringExtra("ImagePath") and do what ever you want.

Putting the whole image or byte-array of image in intent is not a good approach.

Hope it helps you.

Nitesh
  • 3,868
  • 1
  • 20
  • 26