Submit Android intent with POJO as an add-on?

Is their way to put a POJO inside an intent.putExtra object?

I looked at the API and it seems to only support the type string, int, double, boolean, etc., but not the actual POJO / regular Java object.

+3
source share
2 answers

You can use POJO if it implements Serializableor Parcelable. Take a look at intent.putExtra(String, Serializable)or intent.putExtra(String, Parcelable).

+7
source

You can pass them

intent.putExtra(String, Serializable)
intent.putExtra(String, Parcelable)

Also do not forget how to get them

obj = intent.getParcelableExtra(String)
obj = intent.getSerializableExtra(String)

It’s better to implement Parceable because the processor is faster.

+5
source

Source: https://habr.com/ru/post/1768444/


All Articles