小编And*_*iac的帖子

在 Android 设备中以编程方式安装“Google Play 服务”

在我的设备(Karbon A 21 手机)中,Google Play Services未安装时,我的location对象是nullGoogle 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)

gps android-location google-play-services

5
推荐指数
1
解决办法
1569
查看次数