diff options
Diffstat (limited to 'src/com/android/launcher3/GelIntegrationHelper.java')
-rw-r--r-- | src/com/android/launcher3/GelIntegrationHelper.java | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/com/android/launcher3/GelIntegrationHelper.java b/src/com/android/launcher3/GelIntegrationHelper.java index 5f5b81c50..7544e975c 100644 --- a/src/com/android/launcher3/GelIntegrationHelper.java +++ b/src/com/android/launcher3/GelIntegrationHelper.java @@ -81,13 +81,18 @@ public class GelIntegrationHelper { int edge = isLayoutRtl ? EDGE_GESTURE_SERVICE_LEFT_EDGE : EDGE_GESTURE_SERVICE_RIGHT_EDGE; edgeGestureManager.updateEdgeGestureActivationListener(mEdgeGestureActivationListener, edge); - - // Start the Global Search Activity - final SearchManager searchManager = - (SearchManager) launcherActivity.getSystemService(Context.SEARCH_SERVICE); - ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity(); - Intent intent = new Intent(); - intent.setComponent(globalSearchActivity); + // Attempt to use Intent.ACTION_ASSIST, if supported + Intent intent = new Intent(Intent.ACTION_ASSIST); + // Target only the Google Now Activity for right now. + intent.setPackage(GEL_PACKAGE_NAME); + if (!isIntentSupported(launcherActivity, intent)) { + // Start the Global Search Activity + final SearchManager searchManager = + (SearchManager) launcherActivity.getSystemService(Context.SEARCH_SERVICE); + ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity(); + intent = new Intent(); + intent.setComponent(globalSearchActivity); + } try { launcherActivity.startActivity(intent); @@ -96,4 +101,10 @@ public class GelIntegrationHelper { Log.e(TAG, "Unable to launch global search activity."); } } + + private boolean isIntentSupported(Context context, Intent intent) { + PackageManager pm = context.getPackageManager(); + return pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null; + } + } |