Android SearchRecentSuggestions - предложения не отображаются при наборе в SearchView
У меня есть рабочий виджет поиска, и я хочу добавить предложения по истории поиска. Я следовал учебнику по Android (http://developer.android.com/guide/topics/search/adding-recent-query-suggestions.html), и пока поиск все еще работает, предложения не отображаются. Вот мой код:
Поставщик услуг
package com.mypackage;
import android.content.SearchRecentSuggestionsProvider;
public class SearchHistoryProvider extends SearchRecentSuggestionsProvider {
public final static String AUTHORITY = SearchHistoryProvider.class.getName();
public final static int MODE = DATABASE_MODE_QUERIES;
public SearchHistoryProvider() {
setupSuggestions(AUTHORITY, MODE);
}
}
Объявление провайдера в Манифесте
<provider
android:name=".SearchHistoryProvider"
android:authorities="com.mypackage.SearchHistoryProvider">
</provider>
Конфигурация с возможностью поиска
<?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:searchSuggestAuthority="com.mypackage.SearchHistoryProvider"
android:searchSuggestSelection=" ?">
</searchable>
Сохранение запросов к контент-провайдеру (в моей Активности с возможностью поиска)
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
SearchHistoryProvider.AUTHORITY, SearchHistoryProvider.MODE);
suggestions.saveRecentQuery(query, null);
// Collapse the search view as a search is performed
MenuItem searchItem = mMenu.findItem(R.id.search);
SearchView searchView = (SearchView) mMenu.findItem(R.id.search).getActionView();
searchItem.collapseActionView();
searchView.setQuery("", false);
// send the query to the global search activity for loading the data
Intent globalSearchIntent = new Intent(this, GlobalSearchFragmentActivity.class);
GroceryOTGUtils.copyIntentData(intent, globalSearchIntent);
globalSearchIntent.putExtra(GlobalSearchFragmentActivity.GLOBAL_SEARCH, true);
startActivity(globalSearchIntent);
}
}
Все работает отлично, за исключением того, что предложения на самом деле не отображаются (поиск выглядит так же, как и прежде, чем я их добавил). Любая помощь будет принята с благодарностью!