2

Is there a way I can call Google search which from an app? passing it the query string?

I have an app where users type in text and press a button after which i search and/or process the string. for some part I have to pass the string to the search bar.

Gray
  • 115,027
  • 24
  • 293
  • 354
Arjun Ramesh
  • 189
  • 1
  • 12

2 Answers2

2

If you do not need to display the result of the search within your app, this intent might be helpful for you:

http://developer.android.com/reference/android/content/Intent.html#ACTION_WEB_SEARCH

Here is some little example code: http://mobile.dzone.com/articles/android-%E2%80%93-how-implement-google

André Diermann
  • 2,725
  • 23
  • 28
  • ok I wasn't clear in the question. How to call the "google-now search" with query? I know about web search but it does web search only. What if i want to set a reminder ? – Arjun Ramesh Jul 15 '13 at 09:57
  • 1
    Sorry, thought you were refering to the "normal" search. But maybe this undocumented solution works for you as well? https://groups.google.com/d/msg/tasker/mOjAZjMreng/h5-KveRaDFcJ – André Diermann Jul 15 '13 at 10:12
  • Thanks for that, I'm able to start the assist but how to pass query? did not understand the target, category part in that forum. – Arjun Ramesh Jul 15 '13 at 10:34
  • I assume the other values need to be set for your intent object, addCategory(android.intent.category.DEFAULT), putExtra("query", ""), setType()... I think you have to play around a little bit. Sorry that I can not help you further (as said, I thought you were refering to the normal search). – André Diermann Jul 15 '13 at 11:01
1

This seems to achieve what I want:

SearchManager.startSearch takes an initialQuery parameter:

http://developer.android.com/reference/android/app/SearchManager.html#startSearch(java.lang.String,%20boolean,%20android.content.ComponentName,%20android.os.Bundle,%20boolean)

Arjun Ramesh
  • 189
  • 1
  • 12