Partager via


Activity.OnSearchRequested Method

Definition

Overloads

OnSearchRequested()

Called when the user signals the desire to start a search.

OnSearchRequested(SearchEvent)

This hook is called when the user signals the desire to start a search.

OnSearchRequested()

Called when the user signals the desire to start a search.

[Android.Runtime.Register("onSearchRequested", "()Z", "GetOnSearchRequestedHandler")]
public virtual bool OnSearchRequested ();
[<Android.Runtime.Register("onSearchRequested", "()Z", "GetOnSearchRequestedHandler")>]
abstract member OnSearchRequested : unit -> bool
override this.OnSearchRequested : unit -> bool

Returns

Implements

Attributes

Remarks

Java documentation for android.app.Activity.onSearchRequested().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to

OnSearchRequested(SearchEvent)

This hook is called when the user signals the desire to start a search.

[Android.Runtime.Register("onSearchRequested", "(Landroid/view/SearchEvent;)Z", "GetOnSearchRequested_Landroid_view_SearchEvent_Handler", ApiSince=23)]
public virtual bool OnSearchRequested (Android.Views.SearchEvent? searchEvent);
[<Android.Runtime.Register("onSearchRequested", "(Landroid/view/SearchEvent;)Z", "GetOnSearchRequested_Landroid_view_SearchEvent_Handler", ApiSince=23)>]
abstract member OnSearchRequested : Android.Views.SearchEvent -> bool
override this.OnSearchRequested : Android.Views.SearchEvent -> bool

Parameters

searchEvent
SearchEvent

The SearchEvent that signaled this search.

Returns

Returns true if search launched, and false if the activity does not respond to search. The default implementation always returns true, except when in Configuration#UI_MODE_TYPE_TELEVISION mode where it returns false.

Implements

Attributes

Remarks

This hook is called when the user signals the desire to start a search.

You can use this function as a simple way to launch the search UI, in response to a menu item, search button, or other widgets within your activity. Unless overidden, calling this function is the same as calling #startSearch startSearch(null, false, null, false), which launches search for the current activity as specified in its manifest, see SearchManager.

You can override this function to force global search, e.g. in response to a dedicated search key, or to block search entirely (by simply returning false).

Note: when running in a Configuration#UI_MODE_TYPE_TELEVISION or Configuration#UI_MODE_TYPE_WATCH, the default implementation changes to simply return false and you must supply your own custom implementation if you want to support search.

Java documentation for android.app.Activity.onSearchRequested(android.view.SearchEvent).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to