search

start with 1.6 feature list

Here is the API ref for SearchManager

How can I invoke android global search when my activity is in focus

Search for: How can I invoke android global search when my activity is in focus

what is an android application defined search

Search for: what is an android application defined search

Android what is single top singletop launchmode

Search for: Android what is single top singletop launchmode

How can I search across multiple android applications?

Search for: How can I search across multiple android applications?

FLAG_ACTIVITY_SINGLE_TOP

Search for: FLAG_ACTIVITY_SINGLE_TOP

documentation on newintent

Use with setDefaultKeyMode(int) to specify that unhandled keystrokes will start a global search (typically web search, but some platforms may define alternate methods for global search)

Use with setDefaultKeyMode(int) to specify that unhandled keystrokes will start an application-defined search. (If the application or activity does not actually define a search, the the keys will be ignored.)

Can android search results be from multiple applications?

Search for: Can android search results be from multiple applications?

all about android quick search box

Search for: all about android quick search box

implementation of searchable dictionary

The above image is taken from google blogspot. See the blog here


<searchable xmlns:android="http://schemas.android.com/apk/res/android"
       android:label="@string/search_label"
       android:searchSettingsDescription="@string/settings_description"
       android:includeInGlobalSearch="true"
       android:searchSuggestAuthority="dictionary"
       android:searchSuggestIntentAction="android.intent.action.VIEW">
</searchable>

enables your app to participate in suggestions.

The description is useful to the user while he/she is chosing your app to include...


Actual searchable results (e.g. names in the address book) 
Recently entered queries 
Recently viewed data or results 
Contextually appropriate queries or results 
Summaries of possible results

when no query text has been typed yet - an application may also opt to provide zero-query suggestions. These would typically be drawn from the same data source, but because no partial query text is available, they should be weighted based on other factors - for example, most recent queries or most recent results.

SearchRecentSuggestions API


SearchSuggestions suggestions = new SearchSuggestions(this, 
          MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE);
suggestions.saveRecentQuery(queryString, null);

public void saveRecentQuery (String queryString, String line2)

The string as typed by the user. This string will be displayed as the suggestion, and if the user clicks on the suggestion, this string will be sent to your searchable activity (as a new search query).

If you have configured your recent suggestions provider with DATABASE_MODE_2LINES, you can pass a second line of text here. It will be shown in a smaller font, below the primary suggestion. When typing, matches in either line of text will be displayed in the list. If you did not configure two-line mode, or if a given suggestion does not have any additional text to display, you can pass null here.

DATABASE_MODE_2LINES

Search for: DATABASE_MODE_2LINES

This mode bit configures the database to include a 2nd annotation line with each entry

DATABASE_MODE_QUERIES

Search for: DATABASE_MODE_QUERIES

This mode bit configures the database to record recent queries

API reference for these modes in searchrecentsuggestionsprovider


<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/search_label"
    android:hint="@string/search_hint" 
    android:searchMode="showSearchLabelAsBadge"
    
android:searchSuggestAuthority="com.ai.android.search.TestSuggestionProvider"
	android:searchSuggestPath="read-the-caveat-below"
    android:searchSuggestSelection=" ? "
/>

If you define the attribute value android:searchSuggestSelection and include a string, this string will be passed as the selection parameter to your Content Provider's query function. You must define a single selection argument, using the '?' character. The user's query text will be passed to you as the first element of the selection arguments array

To understand this you have to see the signature of the "ContentProvider.query()" method which takes among other things a uri, a single string argument called "selection" (which should be called where clause), an array of strings called "selectionarguments". The value of the searchSuggestSelection will become the "selection" argument. The search string that user has typed will be passed as the first element of the string argument array. It is as simple as that. It is up to the content provider's query method to retrieve the first element of the string argument array and do what is necessary.

note that if this value is not specified then Android assumes that the search query needs to be passed at the end of the uri.


content:// your.suggest.authority 
/ your.suggest.path 
/ SearchManager.SUGGEST_URI_PATH_QUERY

The value "your.suggest.path" is taken from the value of the searchSuggestPath. It is typically unnecessary as the content provider hones in on only one uri signature. The default suggestion provider that you normally inherit from doesn't use this path. So dont add this line if you are using that one.

If you do not define the attribute value android:searchSuggestSelection, then the Search Manager will append another "/" followed by the user's query to the query Uri. The query will be encoding using Uri encoding rules - don't forget to decode it. (See getPathSegments() and getLastPathSegment() for helpful utilities you can use here.)


<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/search_label"
    android:hint="@string/search_hint" 
    android:searchMode="showSearchLabelAsBadge"
    android:includeInGlobalSearch="true"
    
    android:searchSuggestAuthority="com.ai.android.search.TestSuggestionProvider"
    android:searchSuggestSelection=" ? "
/>

type-to-search bug problem global

Search Google for: type-to-search bug problem global

Search Android Developers Group for: type-to-search bug problem global

Search Android Beginers Group for: type-to-search bug problem global

Search Google Code for: type-to-search bug problem global

Search Android Issues Database for: type-to-search bug problem global

quick search box complete action using

Search Google for: quick search box complete action using

Search Android Developers Group for: quick search box complete action using

Search Android Beginers Group for: quick search box complete action using

Search Google Code for: quick search box complete action using

Search Android Issues Database for: quick search box complete action using

type to search bug problem global

Search Google for: type to search bug problem global

Search Android Developers Group for: type to search bug problem global

Search Android Beginers Group for: type to search bug problem global

Search Google Code for: type to search bug problem global

Search Android Issues Database for: type to search bug problem global

searchable dictionary java files

manifest file

searchable.xml

strings.xml

layout-main.xml

layout-word.xml

Note: Replace "." with "searchSuggest"


searchSuggestAuthority
.Path
.Selection
.IntentAction
.IntentData
includeInGloabalSearch
searchSettingsDescription
queryAfterZeroResults
.Threshold

label
icon
searchMode
  showSearchLabelAsBadge
  showSearchIconAsBadge
  queryRewriteFromData
  queryRewriteFromText
inputType
imeOptions

1. Android replicates a suggestion line by default.

2. If you don't want that to happen then you need to include a column


suggest_column_shortcut_id 

and set it to


suggest_never_make_shortcut.

3. If this column contains a value then a query is sent out with the following uri


suggest_uri_path_shortcut

possible followed by the id of the shortcut or suggestion

4. You can indicate a long time opration by including a column


suggest_column_spinner_while_refreshing

format //ignored
text_1
text_2
icon_1
icon_2
intent_action
intent_data
intent_data_id //the last part of the uri
intent_extra_data //has a key of etra_data_key
query //query string to be used
shortcut_id
spinner_while_refreshing
...action key columns

1. will be taken from query column if available

2. if queryRewriteFromData is used, it will be taken from the intent data field

3. if queryReqriteFromText is used, text_1 will be used


content://com.ai.android.search.suggesturlprovider
/search_suggest_query
?limit=58

launching Intent { 
act=android.intent.action.VIEW 
dat=http://www.google.com 
flg=0x10000000 
cmp=com.ai.android.search.custom/.SearchActivity (has extras) 
}

which makes me suspect that the intent actions are always targeted for this activity.

SUGGEST_COLUMN_INTENT_ACTION

Search Google for: SUGGEST_COLUMN_INTENT_ACTION

Search Android Developers Group for: SUGGEST_COLUMN_INTENT_ACTION

Search Android Beginers Group for: SUGGEST_COLUMN_INTENT_ACTION

Search Google Code for: SUGGEST_COLUMN_INTENT_ACTION

Search Android Issues Database for: SUGGEST_COLUMN_INTENT_ACTION

INSTALL_FAILED_CONFLICTING_PROVIDER

Search Google for: INSTALL_FAILED_CONFLICTING_PROVIDER

Search Android Developers Group for: INSTALL_FAILED_CONFLICTING_PROVIDER

Search Android Beginers Group for: INSTALL_FAILED_CONFLICTING_PROVIDER

Search Google Code for: INSTALL_FAILED_CONFLICTING_PROVIDER

Search Android Issues Database for: INSTALL_FAILED_CONFLICTING_PROVIDER

See this thread for an answer


<provider android:name=".search.SearchSuggestionSampleProvider" 
an.droid:authorities="com.example.android.apis.SuggestionProvider" />

<actionkey
     android:keycode="KEYCODE_CALL"
     android:queryActionMsg="call"
     android:suggestActionMsg="call"
     android:suggestActionMsgColumn="call_column" />

queryActionMsg

Search Google for: queryActionMsg

Search Android Developers Group for: queryActionMsg

Search Android Beginers Group for: queryActionMsg

Search Google Code for: queryActionMsg

Search Android Issues Database for: queryActionMsg

Available key codes in KeyEvent


action_down
action_up
keycode_back
keycode_call
keycode_camera
keycode_clear
kecode_endcall
keycode_home
keycode_menu
keycode_mute
keycode_power
keycode_search
keycode_volume_up
keycode_volume_down

Not all these keys are overridable this way

keycode: This is the key code as defined in the KeyEvent API class that should be used to invoke the search activity. There are two times where this key identified by the keycode can be pressed. The first one is when user enters query text in QSB but hasn't navigated to any suggestions. Typically user, with out an action key implementation, would have pressed the search icon of the QSB. With an Action Key specified in the metadata of the search, Android allows the user to click the action key instead of the QSB search icon. The second one is the user navigates to a specific suggestion and then clicks the action key. In both cases the search activity is invoked with an action of ACTION_SEARCH. To know that this action is invoked through an action key look for an extra string called SearchManager.ACTION_KEY. If you see a value here you know that you are being called in response to an action key press.

queryActionMsg: Any text you enter in this element is passed to the search activity invoking intent as an extra string called SearchManager.ACTION_MSG. If you retrieve this message from the intent and it is the same as what you have specified in the metadata then you know that you are being called directly from the QSB (as opposed through a suggestion) and clicking on the action key. With out this test you will not know if the ACTION_SEARCh is called due to an action key click on the suggestion directly.

suggestActionMsg: Any text you enter in this element is passed to the search activity invoking intent as an extra string called SearchManager.ACTION_MSG. So if you notice the extra keys for this and the queryActionMsg are the same. If you give the same value for both of these fields such as say "call", then you will not know in what way the user has invoked the action key. Many cases this is irrelevant in which case you can just give the same value for both. But if you have a need to distinguish one from the other then you will need specify value that is different from the queryActionMsg.

suggestActionMsgColumn: The values queryActionMsg and suggestActionMsg apply globally to this search activity and the suggestion provider. There isn't way to alter the action based on the suggestion. If you would like to do that then you will need to tell the metadata that there is an extra column in the suggestion cursor. This will allow Android to pick up the text from that extra column and send the activity as part of the invoking ACTION_SEARCH intent. Interestingly the value of this additional column is sent through the same extra key in the intent namely: SearchManager.ACTION_MSG.


	public boolean onSearchRequested() 
	{
		Bundle b = new Bundle();
		b.putString("string_key", "hello");
		b.putLong("long_key", 2);
		b.putFloat("float_key", 2.2f);
		
		String queryText = null;
		boolean dontPreSelectText = false;
		boolean dontAlwaysInvokeGlobalSearch = false;
		
		this.startSearch(queryText,
				dontPreSelectText,
				b,
				dontAlwaysInvokeGlobalSearch);
		return true;
	}

Bundle applicationData = 
   queryIntent.getBundleExtra(SearchManager.APP_DATA);
if (applicationData != null)
{
	String s = applicationData.getString("string_key");
	long   l = applicationData.getLong("long_key");
	float  f = applicationData.getFloat("float_key");
}

QUERY
USER_QUERY
APP_DATA
ACTION_KEY
ACTION_MSG
EXTRA_DATA_KEY

SHORTCUT_MIME_TYPE
SUGGEST_MIME_TYPE

SUGGEST_URI_PATH_QUERY
SUGGEST_URI_PATH_SHORTCUT

SUGGEST_NEVER_MAKE_SHORTCUT

ACTION_SEARCH
ACTION_VIEW

android.app.default_searchable

Search for: android.app.default_searchable

android.app.default_searchable value of star *

Search for: android.app.default_searchable value of star *

MD_SEARCHABLE_SYSTEM_SEARCH

Search for: MD_SEARCHABLE_SYSTEM_SEARCH

Looks like this value is deprecated in Searchables.java

Invoking global search by default for an android application

Search for: Invoking global search by default for an android application