禁用的MapView如果不支持它 [英] Disable MapView if it is not supported

查看:91
本文介绍了禁用的MapView如果不支持它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/3410475/how-to-detect-an-android-device-whether-it-supports-google-maps-api">How检测Android设备是否支持谷歌地图API

您好,我已经有多个活动的应用程序。一项活动是MapActivity。我可以禁用时,不支持的设备也MapActivity并让用户安​​装应用程序,并获得剩余活动,或者我应该开发两个版本的应用程序(一个MapActivity,另一个没有它)?

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)?

推荐答案

如果你坚持记录的方法,你坚持写两个应用程序。

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

不过,戴安娜Hackborn指出,有一个无证安卓上的&LT要求属性;使用库&GT; 元素清单。原则上,你可以设置为的谷歌地图插件。原则上,这应该意味着,如果谷歌地图是在设备上,你可以用它正常的,但你的应用程序将安装在缺少这种设备。你可能会需要使用的Class.forName()什么的,看你尝试调用之前,谷歌地图类是否提供给您 startActivity() MapActivity (如禁用菜单选项中启动图)。

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.

这篇关于禁用的MapView如果不支持它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆