当前位置: 首页>>代码示例>>Java>>正文


Java SearchRecentSuggestions类代码示例

本文整理汇总了Java中android.provider.SearchRecentSuggestions的典型用法代码示例。如果您正苦于以下问题:Java SearchRecentSuggestions类的具体用法?Java SearchRecentSuggestions怎么用?Java SearchRecentSuggestions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SearchRecentSuggestions类属于android.provider包,在下文中一共展示了SearchRecentSuggestions类的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();
  }
}
 
开发者ID:charlesng,项目名称:SampleAppArch,代码行数:17,代码来源:ShoppingActivity.java

示例2: setupClearSearchPreference

import android.provider.SearchRecentSuggestions; //导入依赖的package包/类
private void setupClearSearchPreference() {
    Preference clearSearchPreference = findPreference(Constants.PREFERENCES_KEY_CLEAR_SEARCH_HISTORY);

    if (clearSearchPreference != null) {
        clearSearchPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                SearchRecentSuggestions suggestions =
                        new SearchRecentSuggestions(getActivity(),
                                SearchSuggestionProvider.AUTHORITY,
                                SearchSuggestionProvider.MODE);
                suggestions.clearHistory();
                Util.toast(getActivity(), R.string.settings_search_history_cleared);
                return false;
            }
        });
    }
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:19,代码来源:SettingsFragment.java

示例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(QueryReceiverActivity.this, SearchActivity.class);
		intent.putExtra(Constants.INTENT_EXTRA_NAME_QUERY, query);
		startActivityForResultWithoutTransition(QueryReceiverActivity.this, intent);
	}
	finish();
	Util.disablePendingTransition(this);
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:20,代码来源:QueryReceiverActivity.java

示例4: 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);
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:21,代码来源:VoiceQueryReceiverActivity.java

示例5: onCreate

import android.provider.SearchRecentSuggestions; //导入依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Utils.logD(LOG_TAG, "onCreate");

    mSharedPreferences = new PreferencesManagerImp(getActivity().getApplicationContext());
    mLocation = mSharedPreferences.getLocation();
    if (savedInstanceState != null) {
        mRotation = true;
    }
    LoaderProvider loaderProvider = new LoaderProvider(getContext());
    LoaderManager loaderManager = getLoaderManager();
    Geocoder geocoder = new Geocoder(getActivity());
    // loaderManager.enableDebugLogging(true);
    mPresenter = new FindPresenter(mLocation, loaderManager, loaderProvider, geocoder);

    setHasOptionsMenu(true);
    mRecentSearchSuggestions = new SearchRecentSuggestions(getContext(),
            RecentSuggestionsProvider.AUTHORITY, RecentSuggestionsProvider.MODE);
    mCompositeSubscription = new CompositeSubscription();
    mActivityCoordinator = (CoordinatorLayout) getActivity().findViewById(R.id.coordinator);
    mSnackCoordinator = (CoordinatorLayout) getActivity().findViewById(R.id.coordinatorSnackContainer);
}
 
开发者ID:cahergil,项目名称:Farmacias,代码行数:24,代码来源:FindFragment.java

示例6: 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);
    }
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:21,代码来源:SearchActivity.java

示例7: 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();
    }
}
 
开发者ID:vsvankhede,项目名称:foursquared.eclair,代码行数:21,代码来源:SearchVenuesActivity.java

示例8: 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;
        }
    }
}
 
开发者ID:lookwhatlook,项目名称:WeiboWeiBaTong,代码行数:17,代码来源:SearchMainParentFragment.java

示例9: 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;
}
 
开发者ID:AlbertGrobas,项目名称:Leaderboards,代码行数:20,代码来源:MainActivity.java

示例10: 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();
    }
}
 
开发者ID:edsilfer,项目名称:custom-searchable,代码行数:20,代码来源:SearchActivity.java

示例11: queryRecentSuggestionsProvider

import android.provider.SearchRecentSuggestions; //导入依赖的package包/类
private Cursor queryRecentSuggestionsProvider () {
    Uri uri = Uri.parse("content://".concat(providerAuthority.concat("/suggestions")));

    String[] selection;

    if (CustomSearchableInfo.getIsTwoLineExhibition()) {
        selection = SearchRecentSuggestions.QUERIES_PROJECTION_2LINE;
    } else {
        selection = SearchRecentSuggestions.QUERIES_PROJECTION_1LINE;
    }

    String[] selectionArgs = new String[] {"%" + query + "%"};

    return SearchActivity.this.getContentResolver().query(
            uri,
            selection,
            "display1 LIKE ?",
            selectionArgs,
            "date DESC"
    );
}
 
开发者ID:edsilfer,项目名称:custom-searchable,代码行数:22,代码来源:SearchActivity.java

示例12: onOptionsItemSelected

import android.provider.SearchRecentSuggestions; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
    switch (menuItem.getItemId()) {
        case R.id.action_clear_history:
            SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                    MySuggestionProvider.AUTHORITY, MySuggestionProvider.MODE);
            suggestions.clearHistory();
            return true;
        case R.id.action_search:
            onSearchRequested();
            return true;
        case R.id.action_about:
            startActivity(new Intent(this, About.class));
            return true;
        case R.id.action_update_yp:
            YellowPagesLoader.getInstance(this).fetchDataAsync();
            return true;
    }
    return (super.onOptionsItemSelected(menuItem));
}
 
开发者ID:LizaAlert-HotLine,项目名称:AndroidMobileWorkplace,代码行数:21,代码来源:MainActivity.java

示例13: 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);
}
 
开发者ID:takyonxxx,项目名称:Flight-Computer-Android-Flightradar24,代码行数:18,代码来源:SearchQueryResults.java

示例14: 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);
	}

}
 
开发者ID:groupsky,项目名称:android-recipes-app,代码行数:18,代码来源:RecipeItemListActivity.java

示例15: onCreateDialog

import android.provider.SearchRecentSuggestions; //导入依赖的package包/类
@Override
protected Dialog onCreateDialog(int id) {
	switch (id) {
	case CONFIRM_CLEAR_SEARCH_HISTORY_DIALOG:
		return new AlertDialog.Builder(PreferenceSim2Activity.this)
				.setTitle(R.string.confirm_clear_search_title)
				.setMessage(R.string.confirm_clear_search_text)
				.setPositiveButton(android.R.string.ok,
						new AlertDialog.OnClickListener() {
							public void onClick(DialogInterface dialog,
									int which) {
								SearchRecentSuggestions recent = ((MmsApp) getApplication())
										.getRecentSuggestions();
								if (recent != null) {
									recent.clearHistory();
								}
								dialog.dismiss();
							}
						}).setNegativeButton(android.R.string.cancel, null)
				.setIcon(android.R.drawable.ic_dialog_alert).create();
	}
	return super.onCreateDialog(id);
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:24,代码来源:PreferenceSim2Activity.java


注:本文中的android.provider.SearchRecentSuggestions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。