0

Im trying to open. Google Search on my application. But the problem is. when I click the button. the COMPLETE ACTION USING windows is popping up instead of the google search.. search the net for more than an hour but it seems I cant find the solution.. here is my code..

@Override
public void onClick(View view) {
    Intent intent = new Intent("android.intent.action.MAIN");
    intent.setComponent(ComponentName.unflattenFromString("com.google.android.googlequicksearchbox"));
    intent.addCategory("android.intent.category.LAUNCHER");
    startActivity(intent);
flx
  • 14,146
  • 11
  • 55
  • 70

4 Answers4

0

This is due to Android's nature to allow users to make their own decisions. If, for instance, they have Bing installed and prefer it as a search engine over Google, they will have the option to select it. As far as I know, there is no way to open a specific app this way. If the user selects Google and makes it the default app for this action, it will auto-open in successive times, but they must make that conscious decision first.

Adam
  • 2,532
  • 1
  • 24
  • 34
0

have you probably tried to follow this guide..? It describes well about what you might need.. hope it helps..

0
List<ResolveInfo> resolveInfoList = getPackageManager().queryIntentActivities(intent, 0);
for(int i = 0; i < resolveInfoList.size(); i++) {
    ResolveInfo info = resolveInfoList.get(i);
    if (info.activityInfo.packageName.equals("com.google.android.googlequicksearchbox") {
        // that's the one you want
    }
}   

I don't have Eclipse available right now to test it, but this should help you get there. Also check out the documentation for queryIntentActivities()

PS: I'm not sure about that packageName for google search

Vitor M. Barbosa
  • 3,286
  • 1
  • 24
  • 36
0

Try this. This code will search the meaning of value of query variable on google.

String url = "http://www.google.com/search?q=" + "Meaning of " +query;
Intent intentSearch = new Intent(Intent.ACTION_VIEW);
intentSearch.setData(Uri.parse(url));
startActivity(intentSearch); 
Raging Bull
  • 18,593
  • 13
  • 50
  • 55
Shashikant
  • 21
  • 2
  • 8