中国的 Android GPS 位置跟踪

标签 android gps google-play-services

我正在为中国开发一个需要 GPS 位置跟踪的 android 应用程序。 对于位置跟踪,android 需要访问 Google play 服务。但 Google play 服务在中国被阻止。

这个问题有什么解决方法吗?任何推荐的第 3 方库或实现?​​

谢谢

最佳答案

您应该从系统中使用android.location.LocationManager,实现LocationListener,并在LocationManager 上调用requestLocationUpdates

// Acquire a reference to the system Location Manager
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

// Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {
    public void onLocationChanged(Location location) {
      // Called when a new location is found by the network location provider.
      makeUseOfNewLocation(location);
    }

    public void onStatusChanged(String provider, int status, Bundle extras) {}

    public void onProviderEnabled(String provider) {}

    public void onProviderDisabled(String provider) {}
  };

// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

有关详细信息,请参阅 doscthis回答。

关于中国的 Android GPS 位置跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40170829/

相关文章:

objective-c - 在 iPhone 屏幕上绘制罗盘方位

android - 使用 GPS android 获取邮政编码

android - 如何更改/添加 google-services.json 搜索位置

android - 从 Resources 对象中检索所有 Drawable 资源

android - 部分不可编辑的多行编辑文本,例如填空

android - 如何使用 GnssMeasurement 回调获取 Android 7.0 中每个检测到的 GPS 卫星的信噪比?

android - 如何在 Android 中添加 google-services.json?

android - 谷歌播放服务 sdk : Requesting for offline access during auth

Android:如何为发布变体重置 resConfigs?

android - 创建播客应用程序 android - 使用 MediaPlayer 类来播放播客?