From fdf5b35ab46639759d6389a4e2a4d5799cb6814b Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 8 Oct 2014 17:43:48 -0700 Subject: Implement issue #17906468: Allow search request to fall back to global search Change-Id: I04834b2a9f1ec4a68c6a3fed14da2f8dd93b3be7 --- core/java/android/app/Activity.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'core/java/android/app/Activity.java') diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 9f683e3..0e98175 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -3498,14 +3498,24 @@ public class Activity extends ContextThemeWrapper *

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). * - * @return Returns {@code true} if search launched, and {@code false} if activity blocks it. - * The default implementation always returns {@code true}. + *

Note: when running in a {@link Configuration#UI_MODE_TYPE_TELEVISION}, the default + * implementation changes to simply return false and you must supply your own custom + * implementation if you want to support search.

+ * + * @return Returns {@code true} if search launched, and {@code false} if the activity does + * not respond to search. The default implementation always returns {@code true}, except + * when in {@link Configuration#UI_MODE_TYPE_TELEVISION} mode where it returns false. * * @see android.app.SearchManager */ public boolean onSearchRequested() { - startSearch(null, false, null, false); - return true; + if ((getResources().getConfiguration().uiMode&Configuration.UI_MODE_TYPE_MASK) + != Configuration.UI_MODE_TYPE_TELEVISION) { + startSearch(null, false, null, false); + return true; + } else { + return false; + } } /** -- cgit v1.1