How can I pass a Bitmap object from one activity to another

前端 未结 10 1173
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 03:39

In my activity, I create a Bitmap object and then I need to launch another Activity, How can I pass this Bitmap object from the sub-ac

10条回答
  •  佛祖请我去吃肉
    2020-11-22 04:01

    Bitmap implements Parcelable, so you could always pass it with the intent:

    Intent intent = new Intent(this, NewActivity.class);
    intent.putExtra("BitmapImage", bitmap);
    

    and retrieve it on the other end:

    Intent intent = getIntent(); 
    Bitmap bitmap = (Bitmap) intent.getParcelableExtra("BitmapImage");
    

提交回复
热议问题