在没有 GPS 的设备上安装 FINE_LOCATION 的应用程序?

App with FINE_LOCATION installed on devices without GPS?

我的 GPS 应用程序开始安装在没有 GPS 硬件的设备上,例如 Pixel C。我特别要求我的应用程序具有 GPS 级别精度。

我的 build.gradle 文件看起来像

android {
  compileSdkVersion 23
  buildToolsVersion "23.0.1"

  defaultConfig {
    applicationId "my.application.id"
    minSdkVersion 15
    targetSdkVersion 22
  }
}

如何确保我的应用程序只安装在带有 GPS 硬件的设备上?我的应用发生了什么变化?

<uses-feature> page 所述,如果您的目标 API 21 或更高,ACCESS_FINE_LOCATION 不再暗示 android.hardware.location.gps 功能。

虽然在大多数情况下这不会成为问题,因为 Wi-Fi 和 Cell-ID 足够准确,但如果您确实需要 GPS 硬件(例如,如果您是 GPS 导航应用程序或健身应用程序),您可以显式添加

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

如同一页所述,ACCESS_COARSE_LOCATION 也已更改为不需要 android.hardware.location.network 功能。