Search code examples
androidandroid-contentprovider

Search Suggestion results displayed as blank/no text


I have included a Search Dialog in my Activity which works fine. However adding Search Suggestions gives me a little problem: The search suggestion entries are "empty".

I can see my content provider gets called (query(..)) and I return a MatrixCursor with several rows. The suggestions list also shows with (clickable) entries -- but are all blank. Blank as if the string I returned for SUGGEST_COLUMN_TEXT_1 and SUGGEST_COLUMN_TEXT_2 where an empty string.

The columns I use in the MatrixCursor are:

String[] columnNames = {"_ID", "SUGGEST_COLUMN_TEXT_1", "SUGGEST_COLUMN_TEXT_2", "SUGGEST_COLUMN_INTENT_EXTRA_DATA"};

I did try with just the _ID and SUGGEST_COLUMN_TEXT_1 column but same result.

EDIT: And I tried returning a simple "test" string as SUGGEST_COLUMN_TEXT_1 instead of something from my data.

I'm note quite sure what code is relevant here, so please ask for whatever may be needed to figure this out.

I have no idea for where to look for this bug, and my Google-Fu has failed me.

Thanks

(I would like to have added an 'android-search-suggestion' tag, but I'm newguy so it seems I cant)


Solution

  • (Thank you, Jcwenger for teaching the new guy :-)

    The solution, from my comment above:

    Found it. Use SearchManager.SUGGEST_COLUMN_TEXT_1 instead of "SUGGEST_COLUMN_TEXT_1".. (Same for the rest).The String SearchManager.SUGGEST_COLUMN_TEXT_1 maps to "suggest_text_1": http://developer.android.com/reference/android/app/SearchManager.html#SUGGEST_COLUMN_TEXT_1