Search code examples
androidandroid-intentsearch-suggestionandroid-searchmanager

how to get EXTRA_DATA from intent that return Search Suggestions results


I can get the data for this SearchManager.SUGGEST_COLUMN_INTENT_DATA, by using:

intent.getSataString();

My question is, how can I get data for this:

SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA

The context of this question is this:

private final static String[] COLUMN_NAMES = {
        BaseColumns._ID,
        SearchManager.SUGGEST_COLUMN_TEXT_1,
        SearchManager.SUGGEST_COLUMN_TEXT_2,
        SearchManager.SUGGEST_COLUMN_QUERY,
        SearchManager.SUGGEST_COLUMN_INTENT_DATA,
        SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA,
        SearchManager.SUGGEST_COLUMN_INTENT_ACTION};

Solution

  • Looking at the Android docs, I found this:

    public static final String EXTRA_DATA_KEY

    Intent extra data key: This key will be used for the extra populated by the SUGGEST_COLUMN_INTENT_EXTRA_DATA column.

    Constant Value: "intent_extra_data_key"

    So, I tried this:

    String myVal = intent.getExtras().getString(SearchManager.EXTRA_DATA_KEY)

    This worked perfectly.