I have an Android application that has a search function that uses a ContentProvider to query the SQLite database that backs my application. As the user types in their query the application provides custom search suggestions as described by the Android documentation here.
In addition to this I would like the search dialog to display a permanent option at the top of the custom search suggestions that when selected would perform a web search in the browser using the query (e.g., 'Search the web for xyz', or similar). The rest of the suggestions would be the standard search suggestions from my ContentProvider.
Is it possible to do this, and if so, how?
Edit:
David's suggested solution works. I did something like this:
MatrixCursor cursor = new MatrixCursor(new String[] {BaseColumns._ID,
SearchManager.SUGGEST_COLUMN_TEXT_1});
cursor.addRow(new Object[] {0, "I'm always the top suggestion!"});
return new MergeCursor(new Cursor[] {cursor, mySearchSuggestionCursor});
It might be possible with the MergeCursor, I haven't tried it myself but it looks like it was designed for this situation.
You'll have to construct your own cursor with the static data, of course.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With