我的应用程序是以地图为中心的.我requestLocationUpdates()
经常打电话.有一段时间,我exception
打电话给它.或者在任何其他称这种方法的地方.我看到SOF上提出的解决方案,遗憾的是似乎没有什么对我有用.即使我打电话mLocationClient.connect()
,也无法保证它会立即连接,如果我错了,请纠正我.我该如何解决这个问题?
案例R.id.btnContinue:
gpsLocationDailog.cancel();
int isGooglePlayServiceAvilable = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getApplicationContext());
if (isGooglePlayServiceAvilable == ConnectionResult.SUCCESS) {
/** thorws shitty expectiosn **/
mLocationClient.connect();
try {
mLocationClient.requestLocationUpdates(REQUEST, this);
mCurrentLocation = mLocationClient.getLastLocation();
fireQueryToGetTheResponse(latitude, longitude);
rl.setVisibility(View.VISIBLE);
mDrawerLayout.setVisibility(View.GONE);
mSlidingUpPanelLayout.setVisibility(View.GONE);
} catch (IllegalStateException e) {
mLocationClient.connect();
Log.e(TAG, " Waiting for onConnect to be called");
}
} else {
GooglePlayServicesUtil.getErrorDialog(
isGooglePlayServiceAvilable,
SqueakeeMapListViewPager.this, 0).show();
}
break;
Run Code Online (Sandbox Code Playgroud)
这是引发的异常:
java.lang.IllegalStateException: Not connected. Call connect() and wait for onConnected() to be called.
at com.google.android.gms.internal.de.bc(Unknown Source)
at com.google.android.gms.internal.ez.a(Unknown Source) …
Run Code Online (Sandbox Code Playgroud)