0
Hello, I need to transport the contents of an Imageview from one class to another, I tried by Intent, but I couldn’t get through it. I have a Drawable that was edited in Imageview of the first class and I want to transport this already edited content to another Imageview of another class.
I tried this way as shown below, but it did not work..
In first class:
public void next(View v){
//resultView é uma ImageView
Bitmap p = drawableToBitmap(resultView.getDrawable());
Bundle param = new Bundle();
param.putParcelable("BITMAP", p);
Intent intent = new Intent(this, EditImage.class);
intent.putExtras(param);
startActivity(intent);
}
In second class:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
setContentView(R.layout.activity_main);
Intent intent = getIntent();
Bundle param = intent.getExtras();
Bitmap bit = param.getParcelable("BITMAP");
resultView.setImageBitmap(bit);
...
}
Thanks in advance for the help and attention, if anyone has any idea or hint of how to do please inform, all help is valid. Hug!
These images you want to carry, are inside your application?
– Thiago Luiz Domacoski
No, they could be a photo the person just took, or one from the gallery but containing edits. I tried to convert to Bitmap and send, as the example of the question shows, but I was not successful.
– CristianCotrena
What do you mean "it didn’t work out"? There’s some mistake?
– ramaral
Yes, the app stops working with the error (Unfortunately, Namesepp has stopped) Android Studio reports that the error occurs in this line of code ( resultView.setImageBitmap(bit); )
– CristianCotrena