本文整理汇总了Java中android.provider.SearchRecentSuggestions.saveRecentQuery方法的典型用法代码示例。如果您正苦于以下问题:Java SearchRecentSuggestions.saveRecentQuery方法的具体用法?Java SearchRecentSuggestions.saveRecentQuery怎么用?Java SearchRecentSuggestions.saveRecentQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.provider.SearchRecentSuggestions
的用法示例。
在下文中一共展示了SearchRecentSuggestions.saveRecentQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleIntent
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
//set the text on the search view without submission
searchView.setQuery(query, false);
searchView.clearFocus();
//save search result
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
ArtistsSearchRecentSuggestionsProvider.AUTHORITY,
ArtistsSearchRecentSuggestionsProvider.MODE);
suggestions.saveRecentQuery(query, null);
viewModel.query(query);
//use the query to search your data somehow
Toast.makeText(this, query, Toast.LENGTH_SHORT).show();
}
}
示例2: onCreate
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
String query = getIntent().getStringExtra(SearchManager.QUERY);
if (query != null)
{
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(query, null);
Intent intent = new Intent(QueryReceiverActivity.this, SearchActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_QUERY, query);
startActivityForResultWithoutTransition(QueryReceiverActivity.this, intent);
}
finish();
Util.disablePendingTransition(this);
}
示例3: onCreate
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
String query = getIntent().getStringExtra(SearchManager.QUERY);
if (query != null)
{
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(query, null);
Intent intent = new Intent(VoiceQueryReceiverActivity.this, SearchActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_QUERY, query);
intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
startActivityForResultWithoutTransition(VoiceQueryReceiverActivity.this, intent);
}
finish();
Util.disablePendingTransition(this);
}
示例4: onCreate
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
if (getIntent().hasExtra(SearchManager.QUERY)) {
mQuery = getIntent().getStringExtra(SearchManager.QUERY);
}
super.onCreate(savedInstanceState);
if (!TextUtils.isEmpty(mQuery)) {
getSupportActionBar().setSubtitle(mQuery);
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
SearchRecentSuggestionsProvider.PROVIDER_AUTHORITY,
SearchRecentSuggestionsProvider.MODE) {
@Override
public void saveRecentQuery(String queryString, String line2) {
truncateHistory(getContentResolver(), MAX_RECENT_SUGGESTIONS - 1);
super.saveRecentQuery(queryString, line2);
}
};
suggestions.saveRecentQuery(mQuery, null);
}
}
示例5: onNewIntent
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
@Override
public void onNewIntent(Intent intent) {
if (DEBUG) Log.d(TAG, "New Intent: " + intent);
String action = intent.getAction();
String query = intent.getStringExtra(SearchManager.QUERY);
if (intent == null) {
if (DEBUG) Log.d(TAG, "No intent to search, querying default.");
executeSearchTask(query);
} else if (Intent.ACTION_SEARCH.equals(action) && query != null) {
if (DEBUG) Log.d(TAG, "onNewIntent received search intent and saving.");
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
VenueQuerySuggestionsProvider.AUTHORITY, VenueQuerySuggestionsProvider.MODE);
suggestions.saveRecentQuery(query, null);
executeSearchTask(query);
} else {
onSearchRequested();
}
}
示例6: search
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
private void search(final String q) {
if (!TextUtils.isEmpty(q)) {
this.q = q;
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(this.q, null);
switch (viewPager.getCurrentItem()) {
case 0:
((SearchStatusFragment) getSearchWeiboFragment()).search();
break;
case 1:
((SearchUserFragment) getSearchUserFragment()).search();
break;
}
}
}
示例7: onQueryTextSubmit
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
@Override
public boolean onQueryTextSubmit(String query) {
//Avoid bug: this is called twice in some devices (ACTION_UP and ACTION_DOWN)
long actualSearchTime = Calendar.getInstance().getTimeInMillis();
if (actualSearchTime < lastSearchTime + 1000)
return true;
lastSearchTime = actualSearchTime;
if (TextUtils.isEmpty(query)) {
mAdapter.clearAll();
} else {
lastQuery = query;
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
RecentSearchProvider.AUTHORITY, RecentSearchProvider.MODE);
suggestions.saveRecentQuery(query, null);
mAdapter.getFilter().filter(query);
}
return true;
}
示例8: sendSearchIntent
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
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();
}
}
示例9: doSearchQuery
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
private void doSearchQuery(final Intent queryIntent, final String entryPoint) {
// The search query is provided as an "extra" string in the query intent
final String queryString = queryIntent.getStringExtra(SearchManager.QUERY);
// Record the query string in the recent queries suggestions provider.
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
suggestions.saveRecentQuery(queryString, null);
// Do the actual search, write to searchResults field
showDialog(SEARCH_DIALOG);
MapQuestGeocoder geocoder = new MapQuestGeocoder();
geocoder.geocode(queryString, null, this, MAPQUEST_KEY);
}
示例10: onNewIntent
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
if (!TextUtils.isEmpty(query)) {
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
SearchRecipeSuggestionsProvider.AUTHORITY,
SearchRecipeSuggestionsProvider.MODE);
suggestions.saveRecentQuery(query, null);
}
recipeListFragment.setQuery(query);
}
}
示例11: handleIntent
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
viewPager.setCurrentItem(TabPagerAdapter.ANIME_TAB, true);
String query = intent.getStringExtra(SearchManager.QUERY);
if (menuItemSearchView != null) {
MenuItemCompat.collapseActionView(menuItemSearchView);
}
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(
this, SearchFriendsProvider.AUTHORITY,
SearchFriendsProvider.MODE);
suggestions.saveRecentQuery(query, null);
// call method that handles the search request
if (RequestHelper.isNetworkAvailable(FeedTabActivity.this)) {
//startFeedRequests(query);
notifyFragments(query);
} else {
Toast.makeText(this, R.string.no_network_connection_available,
Toast.LENGTH_LONG).show();
}
}
}
示例12: search
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
private void search(String searchQuery, Time goToTime) {
// save query in recent queries
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
Utils.getSearchAuthority(this),
CalendarRecentSuggestionsProvider.MODE);
suggestions.saveRecentQuery(searchQuery, null);
EventInfo searchEventInfo = new EventInfo();
searchEventInfo.eventType = EventType.SEARCH;
searchEventInfo.query = searchQuery;
searchEventInfo.viewType = ViewType.AGENDA;
if (goToTime != null) {
searchEventInfo.startTime = goToTime;
}
mController.sendEvent(this, searchEventInfo);
mQuery = searchQuery;
if (mSearchView != null) {
mSearchView.setQuery(mQuery, false);
mSearchView.clearFocus();
}
}
示例13: requestSearch
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
/**
* 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);
}
示例14: run
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
@Override
public void run() {
//Se a pesquisa não retornou nada, não salva a sugestão.
//Esta verificação não conflitará com outras pesquisas pois está sendo executado na Thread de UI.
if (entityListAdapter.getItemCount() == 0) {
return;
}
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
EntitySearchSuggestionsProvider.AUTHORITY,
EntitySearchSuggestionsProvider.MODE);
suggestions.saveRecentQuery(query, searchEntity);
}
示例15: newIntent
import android.provider.SearchRecentSuggestions; //导入方法依赖的package包/类
public void newIntent(Intent intent)
{
setIntent(intent);
// search action
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestions.AUTHORITY, SearchSuggestions.MODE);
suggestions.saveRecentQuery(query, null);
fromSearch = true;
queryString = query;
}
}