Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Is it possible to insert a permanent option into custom search suggestions?

Tags:

android

search

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});
like image 981
Graeme Duncan Avatar asked Nov 05 '22 23:11

Graeme Duncan


1 Answers

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.

like image 52
David Snabel-Caunt Avatar answered Nov 11 '22 12:11

David Snabel-Caunt