活动应该能够向内容提供商提供上下文信息,如下所示:
@Override
public boolean onSearchRequested() {
Bundle appSearchData = new Bundle();
appSearchData.putByte("category", category);
startSearch(null, false, appSearchData, false);
return true;
}
提供商的搜索建议和结果应限于“类别”,但我找不到从我的ContentProvider访问appSearchData包的位置。
答案 0 :(得分:0)
将此用于onSearchRequested:
@Override
public boolean onSearchRequested() {
SearchManager searchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
if(searchManager!=null)
{
// start the search with the appropriate searchable activity
// so we get the correct search hint in the search dialog
Bundle b = new Bundle();
b.putString("context", indicator);
searchManager.startSearch(null, false,new ComponentName(this, YourClass.class), b, false);
return true;
}
return false;
}
这是你可搜索的课程:
Bundle b = intent.getBundleExtra(SearchManager.APP_DATA);