On Fri, Jul 27, 2012 at 2:33 PM, Luiz Fernando Rodrigues <emaild...@gmail.com> wrote: > In my application I launch an intent to be opened in the google maps > aplication. > > String uri = "geo:0,0?q=" + announcement.getAttribute(MapRegion.ANN_GEO) + > "(" + announcement.getAttribute(MapRegion.ID) + ")"; > Intent intent = new Intent(android.content.Intent.ACTION_VIEW); > intent.setData(Uri.parse(uri)); > startActivity(intent); > > When the device doesn't have the maps API then my application crashes.
Technically speaking, you are crashing because nobody has an activity that handles that particular geo: scheme. Other apps might support that scheme, beyond Google Maps (e.g., OsmAnd). > This feature is optional and I would like to use the maps API externally. > > How can I detect if the maps API is installed so I can protect my code? You do not want to "detect if the maps API is installed". You want to detect whether something can handle your startActivity() request. Again, some users may have devices with other map applications that can handle geo: Uri values. To do that, use resolveActivity() on PackageManager -- if that returns null (or if queryIntentActivities() returns an empty list, if you prefer), you know nothing can handle your startActivity() call with that Intent. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.8 Available! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en