我知道一些手机未预装 Google Play 服务。我想问的是,在不使用 Google Play 服务而只使用 LocationManager 的情况下,是否有可能获取位置信息?
我知道一些手机未预装 Google Play 服务。我想问的是,在不使用 Google Play 服务而只使用 LocationManager 的情况下,是否有可能获取位置信息?
您可以使用LocationManager
LocationManager locationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
使用LocationManager并设置适当的提供者,GPS或NETWORK。您可以使用requestLocationUpdates()和getLastKnownLocation()方法分别获取周期性更新或单个更新。最后,获取一个Location对象,并通过调用Location对象上的所需方法检索纬度和经度。