Loken
Loken

Reputation: 33

search Intent is not working

Can anyone help me understand why this isn't working?

Intent i = new Intent(Intent.ACTION_SEARCH);
    i.setPackage("com.google.android.stardroid");
    i.putExtra(SearchManager.QUERY, "mars");
    startActivity(i);

This is in the oncreate method in the main Activity. I haven't added anything else to the manifest.

The error I'm getting is "No Activity found to handle intent"

Upvotes: 2

Views: 104

Answers (2)

Anubhav Gupta
Anubhav Gupta

Reputation: 2000

This should definitely work

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.android.stardroid");
if (launchIntent != null) { 
    startActivity(launchIntent);//null pointer check in case package name was not found
}

Upvotes: 1

Neil
Neil

Reputation: 11889

Is it possible that the app is not installed, or even is it broken?

Upvotes: 0

Related Questions