Android SearchRecentSuggestions - suggestions do not get displayed when typing in SearchView

随声附和 提交于 2019-12-03 22:21:42

I think the problem was, that the declaration of the SearchHistoryProvider in the Manifest.xml was wrong.

android:name=".SearchHistoryProvider"

Writing .$NAME is a shorthand for $DEFAULTPACKAGE.$NAME, so if your $DEFAULTPACKAGE is 'com.myapp' und you write .SearchHistoryProvider as the android:name of your Provider, Android will simply not find it, as it is located in com.mypackage, as the first line of the following code indicates.

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);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!