Sheehan Alam Sheehan Alam - 4 months ago 27
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


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