如何在Android中两个不同的活动课之间发送的位图位图、活动课、不同、两个

2023-09-12 05:20:20 作者:敬往事一杯酒

在我们的应用程序,我们需要做一些图像处理后,从一个活动类发送一个位图到另一个活动。我们呼吁,在第一个活动的方法,然后我们要显示在第二个活动的输出图像。这两个活动课有不同的布局的XML文件。我们怎样才能做到这一点?

In our application we need to send a bitmap from one activity class to another activity after doing some image processing. We call methods in the first activity and then we want to show the output image in the second activity. The two activity classes have different layout xml files. How can we do that?

推荐答案

的位图是parceable为EboMike说,所以在你的第一个活动,你可以这样做:

the Bitmap is parceable as EboMike said , so in your first Activity , you can do this :

Intent intent = new Intent(this,SecondActivity.class);
intent.putExtras("MYBITMAP",yourImage);
startActivity(intent);

和你SecondActivity,添加此code:

and in your SecondActivity , add this code :

Bitmap imageToDisplay = (Bitmap) this.getIntent().getExtras("MYBITMAP");
//and then you can display it in your imageView :)