From this developer guide,

The database mode must include DATABASE_MODE_QUERIES and can optionally include DATABASE_MODE_2LINES, which adds another column to the suggestions table that allows you to provide a second line of text with each suggestion.

From this reference doc,

public static final int DATABASE_MODE_2LINES

This mode bit configures the database to include a 2nd annotation line with each entry. optional

The question is that where does this annotation line/text come from?

From what I have read in the developer guide so far, we are not providing any annotation text with our search query which would go in the extra column added in the suggestions table, and later served in Recent Suggestion List as the second annotation line.

1

There are 1 answers

0
Solace On BEST ANSWER

You provide it when you save a search query to your collection of recent queries by calling saveRecentQuery(searchQuery, annotationText) on an instance of RecentQuerySuggestions:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent intent  = getIntent();

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                MySuggestionProvider.AUTHORITY, MySuggestionProvider.MODE);
        suggestions.saveRecentQuery(query, null); // *** The second argument is that annotation text
    }
}

Reference

From the reference of saveRecentQuery:

public void saveRecentQuery (String queryString, String line2)

Add a query to the recent queries list. Returns immediately, performing the save in the background.

Parameters queryString The string as typed by the user. This string will be displayed as the suggestion, and if the user clicks on the suggestion, this string will be sent to your searchable activity (as a new search query).

line2 If you have configured your recent suggestions provider with DATABASE_MODE_2LINES, you can pass a second line of text here. It will be shown in a smaller font, below the primary suggestion. When typing, matches in either line of text will be displayed in the list. If you did not configure two-line mode, or if a given suggestion does not have any additional text to display, you can pass null here.