diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index 0ebe3ac09cadb..d6bb7b6d6937e 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -795,7 +795,9 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS SearchableInfo searchable = mSearchable; try { if (searchable.getVoiceSearchLaunchWebSearch()) { - getContext().startActivity(mVoiceWebSearchIntent); + Intent webSearchIntent = createVoiceWebSearchIntent(mVoiceWebSearchIntent, + searchable); + getContext().startActivity(webSearchIntent); } else if (searchable.getVoiceSearchLaunchRecognizer()) { Intent appSearchIntent = createVoiceAppSearchIntent(mVoiceAppSearchIntent, searchable); @@ -810,6 +812,17 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS } }; + /** + * Create and return an Intent that can launch the voice search activity for web search. + */ + private Intent createVoiceWebSearchIntent(Intent baseIntent, SearchableInfo searchable) { + Intent voiceIntent = new Intent(baseIntent); + ComponentName searchActivity = searchable.getSearchActivity(); + voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, + searchActivity == null ? null : searchActivity.toShortString()); + return voiceIntent; + } + /** * Create and return an Intent that can launch the voice search activity, perform a specific * voice transcription, and forward the results to the searchable activity.