Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass text from Activity to Google Now search in Android

I have an activity with EditText and Button. When user is pressing the button i need to launch Google Now Search from my Activity and pass a text from EditText to make Google Now search for this text. How can i do this?

like image 782
bukka.wh Avatar asked Dec 05 '25 05:12

bukka.wh


1 Answers

Try this

String query = editText.getText().toString();
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.setClassName("com.google.android.googlequicksearchbox", "com.google.android.googlequicksearchbox.SearchActivity");
intent.putExtra("query", query);
startActivity(intent);

you can get more info here

like image 128
Udit Mukherjee Avatar answered Dec 07 '25 18:12

Udit Mukherjee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!