views:

30

answers:

1

Hi, I've an application with multiple activities. One activity is a MapActivity. Can I disable MapActivity when it is not supported by the device and let the user install the application and get remaining activities or should I develop two versions of the application (one with MapActivity and another without it)?

A: 

If you stick to documented approaches, you are stuck writing two apps.

However, Dianne Hackborn pointed out that there is an undocumented android:required attribute on the <uses-library> element in the manifest. In principle, you can set that to be false for the Google Maps add-on. In principle, this should mean that if Google Maps is on the device, you can use it normally, but your app would be installable on devices that lack it. You would need to use Class.forName() or something to see whether the Google Maps classes are available to you before you attempt to call startActivity() on your MapActivity (e.g., disable the menu choice that launches the map).

My sincere hope is that this is documented in a future release, and until then you are at risk of this not working, being somehow messed up by a device manufacturer, etc. If nothing else, keep an eye out for it when Gingerbread ships, and hope that it is documented at that time.

CommonsWare
The <i>required</i> atribute seems to work from version 2.0. I'm working on 1.5 version (i haven't specified this). Anyway is a good approach to consider from 2.0 version. Thanks!
Leo2705