如何检测的Andr​​oid设备是否支持谷歌地图API [英] How to detect an android device whether it supports google maps API

查看:142
本文介绍了如何检测的Andr​​oid设备是否支持谷歌地图API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个Android应用程序使用谷歌地图API。

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

我想知道做的所有Android设备的支持地图API,监守这个API是在任意的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.

我需要知道的是编程检测阉的设备支持的地图API和捕获异常和做其他的事情。

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

由于使用地图功能只是我的应用程序的功能之一,我希望让那些不支持地图API仍然可以下载并运行我用了影响我的应用程序的其它功能的应用设备。

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.

任何意见或建议,欢迎

推荐答案

感谢所有球员的帮助!所有的建议都对我很有用!

Thanks for all your guys help! all of your suggestion are useful to me!!

我写了一个简单的应用程序,能够部署在无 - 谷歌地图API的仿真器,并检测谷歌API有问题地presence。

I wrote a simple application that is able to deployed on None-Google-Map API emulator, and detect presence of Google API problematically.

我所做的是我指定<使用库机器人:名称=com.google.android.maps机器人:要求=FALSE/>

(但Android的必需的属性仅适用于2.1和1.6无法正常工作。我需要找出原因。COS的时候我看文件,它说,这归因于1.6支持)

(but android "required" attribute only works for 2.1 and doesn't work for 1.6. I will need to find out why. cos when I had look at the documentation, it says that this attributed supported by 1.6)

因此​​,我能够将应用程序部署到模拟器。

Thus, I am able to deploy the application on to emulator.

其次,我创建了被称为HelloMaps地图活动 在我的主要活动

Secondly, I created a map activity which is called HelloMaps In my main activity

try{
     mapActivity = new Intent(TestApp.this, HelloMaps.class); 
     startActivityForResult(mapActivity, 0); 
}catch(NoClassDefFoundError e){
(Toast.makeText(TestApp.this, "Google Map API not found", Toast.LENGTH_LONG)).show(); 
}

这将捕获的异常,并告诉我,该设备无法运行图的活动。

This will catch the exception and tell me that the device couldn't run map activity.

这篇关于如何检测的Andr​​oid设备是否支持谷歌地图API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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