Aactivity.class
<span style="white-space:pre"> </span> Drawable mDrawable = imageView.getDrawable();
Bitmap bitmap = ((BitmapDrawable) mDrawable).getBitmap();
Bundle bundle = new Bundle();
bundle.putParcelable("bitmap", bitmap);
Intent intent = new Intent(this, PhotoActivity.class);
intent.putExtra("bundle", bundle);
startActivity(intent);
PhotoActivity.class
intent = getIntent();
Bundle bundle=intent.getBundleExtra("bundle");
Bitmap bitmap=bundle.getParcelable("bitmap");
imageview.setImageBitmap(bitmap);
But the above method does not transmit much, there is another way:
Aactivity.class
<span style="white-space:pre"> </span>Intent intent = new Intent(getActivity(), Aactivity.class);
Drawable mDrawable=imageview.getDrawable();
Bitmap bitmap=((BitmapDrawable) mDrawable).getBitmap();
ByteArrayOutputStream bs = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 50, bs);
intent.putExtra("byteArray", bs.toByteArray());
startActivity(intent);
PhotoActivity.class
if(getIntent().hasExtra("byteArray")) {
Bitmap b = BitmapFactory.decodeByteArray(
getIntent().getByteArrayExtra("byteArray"),0,getIntent().getByteArrayExtra("byteArray").length);
imageview.setImageBitmap(b);
}
The above method is still limited.
If you are using ImageLoader, you should use its caching function.
ImageLoader.getInstance().displayImage(imageUri,imageView);
String key=DiskCacheUtils.findInCache(imageUri,ImageLoader.getInstance().getDiskCache()).getPath();
otherActivityImageView.setImageURI(Uri.parse(key));
If the bitmap must be transmitted, in fact, the bitmap should be cached.