GPS清单:GPS的应用程序是可选的,希望把它提供给GPS设备少得把它、可选、提供给、应用程序

2023-09-04 23:18:06 作者:阳光穿透泛白的记忆

在上传我的应用程序推向市场的今天,我看到了,这是只对使用GPS设备,因此这排除了一些药丸。

On uploading my App onto the market today, I saw that it is only available to devices with GPS, so this excludes some tablets.

GPS在我的应用程序是可选的。是否有可能推出一个应用程序的使用和不使用GPS设备或做我需要做一个额外的版本(就没有问题了,虽然)?

GPS in my App is optional. Is it possible to release one App for devices with and without GPS or do I need to make an extra version (would be no problem, though)?

如果有可能,我想有某种方法来检查(deviceHasGPS()){...}。 有一?

If it is possible, I guess there is some sort of method to check if(deviceHasGPS()){...}. Is there one ?

这是我表现的一部分:

<uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />

编辑:感谢您的回答拉哈夫苏德

添加的体现:

<uses-feature android:name="android.hardware.location.gps" 
              android:required="false" />

执行以下操作:

Implement the following:

locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
boolean deviceHasGPS = false;
    if (locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER)) {
        deviceHasGPS = true;
    }

要测试它与GPS的设备上,只是围绕着GPS事情,如果(deviceHasGPS){...} 然后在清单中删除:

to test it on a device with gps, just surround the gps things with if(deviceHasGPS){...} then remove in the manifest:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

设置deviceHasGPS总是错误的,看看在App力关闭。

set deviceHasGPS to always false and see if the App force closes.

推荐答案

以下内容添加到您的清单

Add the following to your manifest

<uses-feature android:name="android.hardware.location.gps" android:required="false" />

这将告诉谷歌播放,当你的应用有GPS,它是绝对的要求是不正确的。但是,你应该处理,而不是让它崩溃缺乏GPS在您的应用程序正常。

This will tell Google Play that while your app has the GPS, it's absolute requirement isn't true. However, you should handle the lack of GPS in your app gracefully, instead of letting it crash.

要检查的设备有GPS可以打电话 LocationManager.getAllProviders(),并检查是否 LocationManager.GPS_PROVIDER 被包括在列表中。

To check is the device has GPS you can call LocationManager.getAllProviders() and check whether LocationManager.GPS_PROVIDER is included in the list.

 
精彩推荐
图片推荐