How to detect an android device whether it supports google maps API

Viewed 11597

I am currently developing an android application uses Google map API.

I am wondering do all android devices support map API, becuase this api is an optinal api and it is an add-on to the platform.

I am worried that my application won't be able to run on that device.

What I need to know is programatically detect wether the device support map API, and catch the exception and do something else.

Because, using map capability is only one of features of my application, I would like to let those devices that don't support map api can still download and run my application with out effecting other features of my app.

Any comment or suggestions are welcome

8 Answers

This worked for me:

Use the (undocumented?) uses-library android:name="com.google.android.maps" android:required="false" in the manifest. This will allow installation in a maps-api non-supported device.

Then check this out: http://android-developers.blogspot.com.ar/2009/01/can-i-use-this-intent.html

You can still have all your maps-api code intact in the app (no need for 2 versions), just code your UI to prevent running it. (In my case I greyed-out a preference). As noted, technique outlined above effectively predicts something that won't work, and allows you to respond (no FCs), instead of just reacting to a problem.

By using adb, To prints all system libraries:

adb shell cmd package list libraries

If your device supports Google Maps, you'll see this line:

library:com.google.android.maps
Related