在我的设备(Karbon A 21 手机)中,Google Play Services未安装时,我的location对象是null,Google Play Services安装时,它返回正确的位置。
我知道我可以检查是否Google Play Services使用 - 安装GooglePlayServicesUtil.isGooglePlayServicesAvailable(this)。但是我可以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);
Run Code Online (Sandbox Code Playgroud)