내 앱은지도 중심적이다. 자주 requestLocationUpdates()
번으로 전화합니다. 가끔씩, 전화가 걸릴 때 exception
이 나옵니다. 또는 그러한 방법을 호출하는 다른 장소에서. SOF에서 제안 된 솔루션을 보았습니다. 슬프게도 나를 위해 아무 것도 작동하지 않는 것 같습니다. 내가 mLocationClient.connect()
라고해도 즉시 연결된다는 보장이 없으며 내가 잘못하면 나를 바로 잡습니다. 이 문제를 어떻게 해결할 수 있습니까?연결되지 않았습니다. Connect를 호출하거나 onConnected()가 호출되기를 기다린다.
경우 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;
이 제기되고 예외 :
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)
at com.google.android.gms.internal.ez$c.bc(Unknown Source)
at com.google.android.gms.internal.ey.requestLocationUpdates(Unknown Source)
at com.google.android.gms.internal.ez.requestLocationUpdates(Unknown Source)
at com.google.android.gms.internal.ez.requestLocationUpdates(Unknown Source)
at com.google.android.gms.location.LocationClient.requestLocationUpdates(Unknown Source)
at org.application.app.squeakee.SqueakeeMapListViewPager.onClick(SqueakeeMapListViewPager.java:1936)
at android.view.View.performClick(View.java:4475)
at android.view.View$PerformClick.run(View.java:18786)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5493)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
at dalvik.system.NativeStart.main(Native Method)
위대한 설명, 감사합니다! – Abby
이러한 종류의 설명은 항상 높이 평가됩니다. 감사! – 0x5f3759df
onConnected() 메서드를 사용하는 경우에도 같은 줄의 코드에서이 오류가 발생했습니다. 그게 뭐야? – Price