我正在为中国开发一个需要 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);
关于中国的 Android GPS 位置跟踪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40170829/