Java 类android.content.SearchRecentSuggestionsProvider 实例源码
项目:custom-searchable
文件:SearchActivity.java
private void sendSearchIntent () {
try {
Intent sendIntent = new Intent(this, Class.forName(searchableActivity));
sendIntent.setAction(Intent.ACTION_SEARCH);
sendIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
sendIntent.putExtra(SearchManager.QUERY, query);
// If it is set one-line mode, directly saves the suggestion in the provider
if (!CustomSearchableInfo.getIsTwoLineExhibition()) {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, providerAuthority, SearchRecentSuggestionsProvider.DATABASE_MODE_QUERIES);
suggestions.saveRecentQuery(query, null);
}
startActivity(sendIntent);
finish();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
项目:custom-searchable
文件:SearchActivity.java
private void getManifestConfig () {
try {
Map<String, String> providers = ManifestParser.getProviderNameAndAuthority(this);
OUTER: for (String key : providers.keySet()) {
providerAuthority = providers.get(key).toString();
providerName = key;
if (Class.forName(providerName).getSuperclass().equals(SearchRecentSuggestionsProvider.class)) {
isRecentSuggestionsProvider = Boolean.TRUE;
break OUTER;
} else {
isRecentSuggestionsProvider = Boolean.FALSE;
}
}
searchableActivity = ManifestParser.getSearchableActivity(this);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
项目:TumCampusApp
文件:ActivityForSearching.java
/**
* Tests if search query is valid and internet connection is available.
* Then starts a new search.
*
* @param query Query to search for
*/
protected void requestSearch(String query) {
mQuery = query;
if (query.length() < mMinLength) {
final String text = String.format(getString(R.string.min_search_len), mMinLength);
Utils.showToast(this, text);
return;
}
/*if (!Utils.isConnected(this)) {
showNoInternetLayout();
return;
}*/
// Add query to recents
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, mAuthority, SearchRecentSuggestionsProvider.DATABASE_MODE_QUERIES);
suggestions.saveRecentQuery(query, null);
// Tell activity to start searching
onStartSearch(query);
}