2

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"

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Loken
  • 33
  • 3
  • Maybe this post should work https://stackoverflow.com/questions/9157490/android-no-activity-found-to-handle-intent-error-how-it-will-resolve – Anubhav Gupta Aug 10 '18 at 19:42

2 Answers2

1

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
}
ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
Anubhav Gupta
  • 2,492
  • 14
  • 27
0

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

Neil
  • 11,059
  • 3
  • 31
  • 56
  • yes you need an actual sky maps app which will receive intent. – Muhammad Zahab Aug 10 '18 at 19:52
  • ahh ok that was my issue....Thanks! Is there anyway to get around this? I guess sky maps would need an api.. – Loken Aug 10 '18 at 19:53
  • What do you mean? The way round it is to make sure the app you want to run is actually installed. – Neil Aug 10 '18 at 19:56
  • Sorry, I mean a way around having to have the sky map app installed. I feel it would be a pain for users to have to install both my app and the sky map app – Loken Aug 10 '18 at 20:14
  • What does your app do? – Neil Aug 10 '18 at 20:16
  • Its an astronomy based app. It will act as a learning tool for amateur astronomers, and I wanted a feature similar to sky map in it, where a user could find a planet they wanted to observe. This wouldn't be that main point of the app, just a side feature. – Loken Aug 10 '18 at 20:19