【发布时间】:2016-09-26 17:42:31
【问题描述】:
我注意到可以(至少)以两种不同的方式请求位置更新。
-
使用
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);
Google 似乎在他们的教程"Receiving Location Updates" 中推广了方法1。我不清楚1 方法的好处是什么,因为2 方法对我来说同样有效(我在应用程序的两个不同位置使用这两种方法)。
【问题讨论】:
-
也检查这个答案link
标签: android android-mapview android-maps-v2 android-location android-googleapiclient