我注意到有可能以(至少)两种不同的方式请求位置更新。为什么使用GoogleAPIClient请求位置更新?
使用
GoogleAPIClient
:// Callback for when the GoogleAPIClient is connected @Override public void onConnected(Bundle connectionHint) { LocationServices.FusedLocationApi.requestLocationUpdates( mGoogleApiClient, mLocationRequest, this); }
使用
LocationManager
:LocationManager locationManager = (LocationManager) getActivity(). getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
谷歌似乎促进法1
在他们的教程"Receiving Location Updates"。目前还不清楚方法1
的好处是什么,因为方法2
对我来说同样适用(我在应用程序的两个不同位置使用这两种方法)。
也检查这个答案[链接](http://stackoverflow.com/questions/37395614/locationmanager-uses-fusedlocationproviderapi/37396211#37396211) – Blackkara