0

I have the code:

final ArrayList<byte[]> Picture = new ArrayList<byte[]>();

.....
......
.....
....
 Intent myIntent = new Intent(PageAndExercise.this, theAnswers.class);

    myIntent.putExtra("Picture", Picture);
    startActivity(myIntent);

How can I get the Pictuer arraylist from the extra? Thanks

Ron
  • 51
  • 4

2 Answers2

1

You can not pass an arraylist of bytes [] via intent, you can populate the bundles with the images with a for loop, but would cause a failed transaction binder.

You can also pass a picture through bitmap as Parcelable but even that would cause a failed transaction binder.

So you have to save images as bitmaps in a temporary folder and recover in the second activity, converting them back to byte []

There are enough explanations in this post how do you pass images (bitmaps) between android activities using bundles? to not duplicate

Community
  • 1
  • 1
Blaken
  • 21
  • 1
  • 2
  • 3
0

Because it is an arrayList, I suggest you use

putStringArrayListExtra("Key", ArrayList<String> value)

Now, to get the values use

ArrayList<String> list =  getIntent().getStringArrayListExtra("key");

Now, you have retrieved the values of your arrayList into a new arrayList. This new arraylist contains the content of your arrayList, and then you can just use the new arrayList for whatever code you want to execute later.

If this was helpful, mark it as best answer. If you have any more questions, feel free to ask!

Best of luck,

{Rich}
Ruchir Baronia
  • 7,406
  • 5
  • 48
  • 83