以编程方式找到的设备支持GPS或不? [英] Programmatically find device support GPS or not?

查看:112
本文介绍了以编程方式找到的设备支持GPS或不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一些code,这将帮我看看,我用该设备具有GPS或不?我不想知道GPS是启用或禁用。我只是想知道,如果该设备具有GPS硬件或不通过我的程序。

I am trying to find some code which will help me to find out if the device which I use has GPS or not? I don't want to know if GPS is enabled or disabled. I just want to know if the device has GPS hardware or not through my program.

推荐答案

是的,这是可以做到。

您可以拨打<一个href="http://developer.android.com/reference/android/location/LocationManager.html#getAllProviders%28%29"><$c$c>LocationManager.getAllProviders()并检查是否 LocationManager.GPS_PROVIDER 包含在列表中。

You can call LocationManager.getAllProviders() and check whether LocationManager.GPS_PROVIDER is included in the list.

仅供参考,我相信所有已发布的Andr​​oid手机都配备了GPS。这不是说Android的似乎是担心,例如:提GPS作为由<返回的设备属性之一href="http://developer.android.com/intl/fr/reference/android/content/pm/PackageManager.html#getSystemAvailableFeatures%28%29"><$c$c>PackageManager.getSystemAvailableFeatures().

Just for reference, I believe all released Android phones come with a GPS. It's not something that Android seem to be worrying about, e.g. mentioning GPS as one of the device attributes returned by PackageManager.getSystemAvailableFeatures().

这篇关于以编程方式找到的设备支持GPS或不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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