当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Send an android Intent with an POJO as an Intent extra?

问题描述:

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

I have looked into the API's and it only seems to support of type string, int, double, boolean etc but not a actual POJO/regular java object.

网友答案:

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

网友答案:

You can pass them

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

Also don't forget how to get them

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

Better implement Parceable because it's CPU faster.

分享给朋友:
您可能感兴趣的文章:
随机阅读: