'SearchActivity not starting search from intent automatically
In my app there is a function to open the Search Google app with a request:
Intent intent = new Intent(Intent.ACTION_SEARCH);
intent.setClassName("com.google.android.googlequicksearchbox", "com.google.android.googlequicksearchbox.SearchActivity");
intent.putExtra(SearchManager.QUERY, string);
activity.startActivity(intent);
The code above used to work, I remember it, now it does not work the same because the search activity opens but the search field is just populated with the string value, but the search is not started, so the user has to hit the Enter button. The suggestions based on that string are listed.
It seems to depend on the Android version, or on some recent update, maybe? The behavior is different I think. I tried with Android 11 on my smartphone.
I also tried to append \n to the string but only a trailing space is displayed.
If the ACTION_WEB_SEARCH intent is used the search function itself is different, it is performed only on the web, not including local results, but the search is effectively started, the user has not confirm it.
Is there any workaround for this? I want to use the ACTION_SEARCH intent.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
