내 앱은 GoogleApiClient
을 사용하여 현재 위치를 가져옵니다. 그것은 처음에는 잘 작동하지만 내 응용 프로그램을 닫은 다음 다시 열면 충돌이 발생합니다 (Sony Xperia Z3, Google Pixel).GoogleApiClient.connect()가 충돌을 일으킴
... 내가 또한 최신 Google API 11.8.0
에 try-catch
업데이트를 사용할 수는 없지만,
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.view.IWindow$Stub$Proxy.onAnimationStopped(IWindow.java:534)
at com.android.server.wm.WindowAnimator.updateWindowsLocked(WindowAnimator.java:286)
at com.android.server.wm.WindowAnimator.animateLocked(WindowAnimator.java:678)
at com.android.server.wm.WindowAnimator.access$000(WindowAnimator.java:53)
at com.android.server.wm.WindowAnimator$1.doFrame(WindowAnimator.java:123)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:856)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:603)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:234)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
나는 충돌이 GoogleApiClient.connect()
입니다 원인 코드의 라인을 발견 충돌하지 않습니다 가능한 해결책을 찾으십시오. 여기에 내 코드
@Override
public void onLocationChanged(Location location) {
if (location != null) {
Log.v(">>>", "onLocationChanged Longitude = " + Constants.location.getLongitude() + ", Latitude = " + Constants.location.getLatitude());
//Toast.makeText(this, "onLocationChanged Longitude = " + Constants.location.getLongitude() + ", Latitude = " + Constants.location.getLatitude(), Toast.LENGTH_SHORT).show();
saveLocation(location);
}
}
@Override
public void onConnected(@Nullable Bundle bundle) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
try {
Location mLastLocation = LocationServices.FusedLocationApi
.getLastLocation(mGoogleApiClient);
if (mLastLocation != null) {...}
//Toast.makeText(this, "onConnected Longitude = " + Constants.location.getLongitude() + ", Latitude = " + Constants.location.getLatitude(), Toast.LENGTH_SHORT).show();
}
startLocationUpdates();
} catch (Exception ex) {
// This will catch the exception, handle as needed
}
}
//Toast.makeText(this, "onConnected", Toast.LENGTH_SHORT).show();
}
@Override
public void onConnectionSuspended(int i) {
mGoogleApiClient.connect();
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.d("Location service", "onConnectionFailed");
}
@Override
protected void onResume() {
super.onResume();
checkPlayServices();
// Resuming the periodic location updates
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
startLocationUpdates();
}
Log.v(">>>", "onResume");
}
@Override
protected void onStart() {
super.onStart();
if (mGoogleApiClient != null) {
mGoogleApiClient.connect(); // CRASH HERE
Log.v(">>>", "GoogleApiClient.connect()");
}
Log.v(">>>", "onStart");
}
@Override
protected void onStop() {
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
mGoogleApiClient = null;
Log.v(">>>", "GoogleApiClient.disconnect()");
}
super.onStop();
Log.v(">>>", "onStop");
}
@Override
protected void onPause() {
stopLocationUpdates();
super.onPause();
Log.v(">>>", "onPause");
}
Google 픽셀 및 Sony Xperia Z3의 OS 버전은 무엇입니까? – Soham
Android 6에서 그런 상황에 처한 적이 있습니까? – nightmaregiba
안드로이드 6에서는 안된다.하지만 최근에 나는 오레오에서 이와 같이 직면했다. 그래서 그것이 내가 묻는 이유이다. – Soham