Noman Arain
Noman Arain

Reputation: 1162

What is the purpose of onSearchRequested()?

What is the purpose of onSearchRequested()? I am referring to here: http://developer.android.com/reference/android/app/Activity.html#onSearchRequested%28%29

The following is stated: "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)." Specifically, what does the bolded piece mean? Does it not mean that we are able to disable this button? I just had a heated discussion at: Android - How to disable Search button, how to implement onSearchRequested()?

As you can see, Phil is suggesting that I have to go the other route. My questions are: can JUST this function be used to disable the search button completely? Can just this function be used without having to disable this button from the dialog builder? What did google meant with the above quoted statement? Thank you for your time.

Upvotes: 1

Views: 196

Answers (1)

Excalibur
Excalibur

Reputation: 467

You should be able to disable the search button using it, i would think google mean that you can block someone trying to search from within your app( IE skipping a progress dialog) but since most android phones don't come with search buttons anymore, its not a very used function.

and yes you should be able to disable it on the fly without going through the dialog builder.

Swift

Upvotes: 1

Related Questions