how do you pass images (bitmaps) between android activities using bundles?

后端 未结 9 1194
自闭症患者
自闭症患者 2020-11-22 09:56

Suppose I have an activity to select an image from the gallery, and retrieve it as a BitMap, just like the example: here

Now, I want to pass this BitMap to be used i

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 10:34

    Write this code from where you want to Intent into next activity.

        yourimageView.setDrawingCacheEnabled(true); 
        Drawable drawable = ((ImageView)view).getDrawable(); 
        Bitmap bitmap = imageView.getDrawingCache();
        Intent intent = new Intent(getBaseContext(), NextActivity.class);
        intent.putExtra("Image", imageBitmap);
    

    In onCreate Function of NextActivity.class

    Bitmap hotel_image;
    Intent intent = getIntent();
    hotel_image= intent.getParcelableExtra("Image");
    

提交回复
热议问题