Java Code Examples for android.provider.SearchRecentSuggestions#saveRecentQuery()
The following examples show how to use
android.provider.SearchRecentSuggestions#saveRecentQuery() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchActivity.java From materialistic with Apache License 2.0 | 6 votes |
@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); } }
Example 2
Source File: MainActivity.java From Leaderboards with Apache License 2.0 | 6 votes |
@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; }
Example 3
Source File: SearchActivity.java From custom-searchable with Apache License 2.0 | 6 votes |
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(); } }
Example 4
Source File: RecipeItemListActivity.java From android-recipes-app with Apache License 2.0 | 6 votes |
@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); } }
Example 5
Source File: TagActivity.java From droidddle with Apache License 2.0 | 5 votes |
private void saveQuery(String query) { if (TextUtils.isEmpty(query)) { return; } SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchProvider.AUTHORITY, SearchProvider.MODE); suggestions.saveRecentQuery(query, null); }
Example 6
Source File: SearchActivity.java From droidddle with Apache License 2.0 | 5 votes |
private void saveQuery(String query) { if (TextUtils.isEmpty(query)) { return; } SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchProvider.AUTHORITY, SearchProvider.MODE); suggestions.saveRecentQuery(query, null); }
Example 7
Source File: SearchMainActivity.java From iBeebo with GNU General Public License v3.0 | 5 votes |
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE); suggestions.saveRecentQuery(query, null); search(query); } }
Example 8
Source File: SearchMainActivity.java From iBeebo with GNU General Public License v3.0 | 5 votes |
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE); suggestions.saveRecentQuery(query, null); search(query); } }
Example 9
Source File: SearchableActivity.java From Androzic with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); Toolbar toolbar = (Toolbar) findViewById(R.id.action_toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); listView = (ListView) findViewById(android.R.id.list); finishHandler = new FinishHandler(this); if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) { String query = getIntent().getStringExtra(SearchManager.QUERY); SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SuggestionProvider.AUTHORITY, SuggestionProvider.MODE); suggestions.saveRecentQuery(query, null); } adapter = new SearchResultsListAdapter(this, results); listView.setAdapter(adapter); listView.setOnItemClickListener(this); progressBar = (ProgressBar) findViewById(R.id.progressbar); handleIntent(getIntent()); }
Example 10
Source File: SearchQueryResults.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
/** * Generic search handler. * * In a "real" application, you would use the query string to select results from * your data source, and present a list of those results to the user. */ 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); mQueryText.setText(queryString); // Record the query string in the recent queries suggestions provider. SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestionSampleProvider.AUTHORITY, SearchSuggestionSampleProvider.MODE); suggestions.saveRecentQuery(queryString, null); // If your application provides context data for its searches, // you will receive it as an "extra" bundle in the query intent. // The bundle can contain any number of elements, using any number of keys; // For this Api Demo we're just using a single string, stored using "demo key". final Bundle appData = queryIntent.getBundleExtra(SearchManager.APP_DATA); if (appData == null) { mAppDataText.setText("<no app data bundle>"); } if (appData != null) { String testStr = appData.getString("demo_key"); mAppDataText.setText((testStr == null) ? "<no app data>" : testStr); } // Report the method by which we were called. mDeliveredByText.setText(entryPoint); }
Example 11
Source File: MediathekSearchSuggestionsProvider.java From zapp with MIT License | 4 votes |
public static void saveQuery(Context context, String query) { SearchRecentSuggestions suggestions = new SearchRecentSuggestions(context, AUTHORITY, MODE); suggestions.saveRecentQuery(query, null); }