2

I have an android application which allows the user to open up google maps or navigator to show a certain address. This functionality was working in the past, but now I get the following error and the app crashes:

ERROR/AndroidRuntime(2165): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=google.navigation:q=MCNAMARA+TERMINAL+ROMULUS+MI+48174 }

The two intents I'm using are-

1) For Map:

    String uri = "geo:0,0?q=MCNAMARA+TERMINAL+ROMULUS+MI+48174";        
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
    startActivity(i); 

2) For Navigator:

    String uri = "google.navigation:q=MCNAMARA+TERMINAL+ROMULUS+MI+48174";
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
    startActivity(i); 
Tom G
  • 2,595
  • 5
  • 20
  • 16

2 Answers2

7

Your first Intent should be fine on many devices, as that is documented and supported.

Your second Intent is neither documented nor supported AFAIK, and so you should not be using it.

Also, bear in mind that not every Android device will have Google Maps or Navigation. Use PackageManager and queryIntentActivities() to determine if anything will respond to your Intent, then disable UI paths as needed to prevent users from encountering the exception.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    That, and/or add exception handling to notify the user if the activity couldn't be started (and suggest that a necessary application MAY not be installed). – EboMike Aug 18 '10 at 23:39
  • 1
    It may be the second intent isn't documented since the navigation app it invokes is still in Beta. I thought the intent system should inform the user if there is no app installed on their device to support the requested intent. Maybe in this case we have to catch the error ourselves and perhaps forward the user to good maps web page. – topwik Jan 03 '13 at 20:36
0

Intent for starting Navigator:

Intent navigation = new Intent(Intent.ACTION_VIEW, Uri.parse(“http://
maps.google.com/maps?
saddr=42.35892,-71.05781&daddr=40.756054,-73.986951”));
 startActivity(navigation);

More details can be found here.

AlexAndro
  • 1,918
  • 2
  • 27
  • 53
  • that's good for starting the google maps navigation in a browser it seems, but the OP is wanting to invoke the native Google Navigator app – topwik Jan 03 '13 at 20:37