Java Code Examples for android.app.SearchManager#SUGGEST_COLUMN_QUERY
The following examples show how to use
android.app.SearchManager#SUGGEST_COLUMN_QUERY .
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: CustomSuggestionsProvider.java From custom-searchable with Apache License 2.0 | 6 votes |
private Cursor getFakeData () { // Columns explanation: http://developer.android.com/guide/topics/search/adding-custom-suggestions.html#HandlingSuggestionQuery MatrixCursor mc = new MatrixCursor(new String[] { "_ID", SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_TEXT_2, SearchManager.SUGGEST_COLUMN_ICON_1, SearchManager.SUGGEST_COLUMN_ICON_2, SearchManager.SUGGEST_COLUMN_INTENT_ACTION, SearchManager.SUGGEST_COLUMN_INTENT_DATA, SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA, SearchManager.SUGGEST_COLUMN_QUERY, }); Object[] fakeRow1 = {"ID1", "Mock data 1", "Sub mock data 1", R.drawable.delete_icon, R.drawable.arrow_left_icon, null, null, null, null, null}; Object[] fakeRow2 = {"ID2", "Mock data 2", "Sub mock data 2", R.drawable.mic_icon, R.drawable.delete_icon, null, null, null, null, null}; Object[] fakeRow3 = {"ID3", "Mock data 3", "Sub mock data 3", null, null, null, null, null, null, null}; mc.addRow(fakeRow1); mc.addRow(fakeRow2); mc.addRow(fakeRow3); return mc; }
Example 2
Source File: SearchRecentSuggestionsProvider.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * In order to use this class, you must extend it, and call this setup function from your * constructor. In your application or activities, you must provide the same values when * you create the {@link android.provider.SearchRecentSuggestions} helper. * * @param authority This must match the authority that you've declared in your manifest. * @param mode You can use mode flags here to determine certain functional aspects of your * database. Note, this value should not change from run to run, because when it does change, * your suggestions database may be wiped. * * @see #DATABASE_MODE_QUERIES * @see #DATABASE_MODE_2LINES */ protected void setupSuggestions(String authority, int mode) { if (TextUtils.isEmpty(authority) || ((mode & DATABASE_MODE_QUERIES) == 0)) { throw new IllegalArgumentException(); } // unpack mode flags mTwoLineDisplay = (0 != (mode & DATABASE_MODE_2LINES)); // saved values mAuthority = new String(authority); mMode = mode; // derived values mSuggestionsUri = Uri.parse("content://" + mAuthority + "/suggestions"); mUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); mUriMatcher.addURI(mAuthority, SearchManager.SUGGEST_URI_PATH_QUERY, URI_MATCH_SUGGEST); if (mTwoLineDisplay) { mSuggestSuggestionClause = "display1 LIKE ? OR display2 LIKE ?"; mSuggestionProjection = new String [] { "0 AS " + SearchManager.SUGGEST_COLUMN_FORMAT, "'android.resource://system/" + com.android.internal.R.drawable.ic_menu_recent_history + "' AS " + SearchManager.SUGGEST_COLUMN_ICON_1, "display1 AS " + SearchManager.SUGGEST_COLUMN_TEXT_1, "display2 AS " + SearchManager.SUGGEST_COLUMN_TEXT_2, "query AS " + SearchManager.SUGGEST_COLUMN_QUERY, "_id" }; } else { mSuggestSuggestionClause = "display1 LIKE ?"; mSuggestionProjection = new String [] { "0 AS " + SearchManager.SUGGEST_COLUMN_FORMAT, "'android.resource://system/" + com.android.internal.R.drawable.ic_menu_recent_history + "' AS " + SearchManager.SUGGEST_COLUMN_ICON_1, "display1 AS " + SearchManager.SUGGEST_COLUMN_TEXT_1, "query AS " + SearchManager.SUGGEST_COLUMN_QUERY, "_id" }; } }
Example 3
Source File: SearchSuggestionDao.java From lttrs-android with Apache License 2.0 | 4 votes |
@Query("select id as "+ BaseColumns._ID +", `query` as "+ SearchManager.SUGGEST_COLUMN_TEXT_1+","+ R.drawable.ic_restore_24dp +" as "+SearchManager.SUGGEST_COLUMN_ICON_1+",`query` as "+SearchManager.SUGGEST_COLUMN_QUERY+" from search_suggestion where `query` like :needle and `query` is not :actual order by id desc limit 30") abstract Cursor getSearchSuggestions(String needle, String actual);