Last active
March 27, 2017 10:41
-
-
Save bdiegel/688573d4e989a32f8ac0 to your computer and use it in GitHub Desktop.
Android combined recent and custom search suggestions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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