【发布时间】:2023-03-20 04:40:01
【问题描述】:
在我的设备(Karbon A 21 手机)中,当没有安装Google Play Services 时,我的location 对象是null,而当安装了Google Play Services 时,它返回正确的位置。
我知道我可以使用-GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) 检查Google Play Services 是否已安装。
但是我可以实际安装Google Play Services 还是应该要求用户手动安装?
为什么即使Google Play Services没有安装其他应用程序显示位置?
我在我的代码中做错了什么。请参阅下面的代码。
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setCostAllowed(true);
provider = locationManager.getBestProvider(criteria, true);
Location location = locationManager.getLastKnownLocation(provider);
【问题讨论】:
-
我在安装
Google Play Services时也遇到了同样的问题。
标签: gps google-play-services android-location