我正在创建可搜索的字典,我想将用户在 SearchView 中所做的最新查询显示给其他活动。就像 android 词典中的最近选项一样。
private void handleIntent(Intent inent) {
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
// handles a click on a search suggestion; launches activity to show word
Intent wordIntent = new Intent(this, WordActivity.class);
wordIntent.setData(intent.getData());
startActivity(wordIntent);
finish();
} else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
// handles a search query
String query = intent.getStringExtra(SearchManager.QUERY);
SearchRecentSuggestions suggestions=new SearchRecentSuggestions(this, MySuggestionProvider.AUTHORITY, MySuggestionProvider.MODE);
suggestions.saveRecentQuery(query, null);
showResults(query);
}
}
ShowResult 在搜索活动中显示查询建议,我想将最近的查询显示到其他活动中,我该怎么做?