I have a Set where the class Prova implements Serializable. I must put this Set in a intent. This is the code:
Set<Prova> set=..... // Set is declared first and it's not null
Intent intent = new Intent(getApplicationContext(), Example.class);
intent.putExtra("set",set);
This code gives me: "cannot Resolve method". Anyone can help me?
Try using HashSet
instead of Set
and then you can do something like this -
HashSet<Prova> set = new HashSet<>();
Intent intent = new Intent(getApplicationContext(), Example.class);
intent.putExtra("mySet", set);;
Set
itself does not implement Serializable
but HashSet
does and Intent can hold an instance of any class that implements Serializable or Parcelable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With