In my application, I am trying to pass a serializable object through the intent of another action. The goal is not completely created by me, it is created and transmitted through the search sentence.
In the content provider for the search clause, an object is created and placed in the SUGGEST_COLUMN_INTENT_EXTRA_DATA MatrixCursor column. However, when I call getIntent().getSerializableExtra(SearchManager.EXTRA_DATA_KEY) in the receiving activity, the returned object is of type String and I cannot pass it to the source class of the object.
I tried to make a batch wrapper for my object that calls out.writeSerializable(...) , and use this instead, but the same thing happened.
The returned string is similar to a common toString () object, i.e. com.foo.yak.MyAwesomeClass@4350058 , so I assume that toString () is called somewhere where I do not control.
Hope I just missed something simple. Thanks for the help!
Edit: part of my code
This is in a content provider that acts as a search authority:
//These are the search suggestion columns private static final String[] COLUMNS = { "_id", // mandatory column SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA }; //This places the serializable or parcelable object (and other info) into the search suggestion private Cursor getSuggestions(String query, String[] projection) { List<Widget> widgets = WidgetLoader.getMatches(query); MatrixCursor cursor = new MatrixCursor(COLUMNS); for (Widget w : widgets) { cursor.addRow(new Object[] { w.id w.name w.data //This is the MyAwesomeClass object I'm trying to pass }); } return cursor; }
This is the action that receives the search suggestion:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Object extra = getIntent().getSerializableExtra(SearchManager.EXTRA_DATA_KEY);
source share