Skip to content

Instantly share code, notes, and snippets.

@bdiegel
Last active March 27, 2017 10:41
Show Gist options
  • Save bdiegel/688573d4e989a32f8ac0 to your computer and use it in GitHub Desktop.
Save bdiegel/688573d4e989a32f8ac0 to your computer and use it in GitHub Desktop.
Android combined recent and custom search suggestions
/**
* It's possible to combine recent and custom search suggestions. One way is to
* write a custom provider that extends SearchRecentSuggestionsProvider. If the
* custom provider has the same columns as SearchRecentSuggestionsProvider
* then the cursors can be easily 'merged'.
*
* In the .query() method of custom search provider, return the combined results:
*/
Cursor recentCursor = super.query(uri, projection, sel, selArgs, sortOrder);
Cursor[] cursors = new Cursor[] { recentCursor, customCursor};
return new MergeCursor(cursors);
// details: http://stackoverflow.com/questions/11329535/recent-searches-are-not-displayed-custom-suggestions-are
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment