Search code examples
androidsearchandroid-4.0-ice-cream-sandwichvoice

Why is APP_DATA bundle not passed to search results activity on Android 4 when using voice search?


I have a searchable app that works fine on Android 2.2. I can search either by typing or by using voice search and the bundle that I pass to startSearch is available in the intent extras in the search results activity (under the SearchManager.APP_DATA key).

However, when running this same app on a device running Android 4.0.4 (I've tried two different devices - one HTC and one Samsung) the bundle is only passed to the results activity when searching using the keyboard. Using voice search it is missing. I have confirmed that the bundle is being created and passed to startSearch. It goes missing at some point after that.

For what it's worth, this is my searchable.xml:

<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
            android:label="@string/app_name"
            android:hint="@string/search_hint"
            android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
            android:voiceLanguageModel="web_search"
            android:voiceLanguage="en">
</searchable>

And this is where I invoke startSearch:

@Override
public boolean onSearchRequested()
{
    Bundle data = new Bundle();
    data.putParcelable(URI_EXTRA, getIntent().getParcelableExtra(URI_EXTRA));
    data.putString(NAME_EXTRA, getIntent().getStringExtra(NAME_EXTRA));
    startSearch(null, false, data, false);
    return true;
}

In onCreate in the search results activity I attempt to retrieve the bundle as follows but it is null:

Bundle data = getIntent().getBundleExtra(SearchManager.APP_DATA);

Any ideas what might cause this or know how to work around it?


Solution

  • I believe this issue has been fixed in the android sources with the following commit https://github.com/android/platform_frameworks_base/commit/1bcfe84179417cda57176fe8661a4a749cb843b6