Sheehan Alam Sheehan Alam - 1 year ago 171
Java Question

How to pass custom object in Bundle?

I am trying to pass my own custom object into a bundle:

Bundle b = new Bundle();
STMessage message = (STMessage)a.getAdapter().getItem(position);

I get the error:

The method putObject(String, Object) is undefined for the type Bundle

Answer Source

One way is to have your custom object implement the Parcelable interface and use Bundle.putParcelable/Bundle.getParcelable

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download