는 내가 가지고 그 코드의다음 활동으로 가기 전에 MyActivity가 GoogleApiClient 콜백을 기다리는 이유는 무엇입니까?
GoogleApiClientUtility googleApiClientUtility = new GoogleApiClientUtility(
app.getGoogleApiClient(),
new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(@Nullable Bundle bundle) {
try { sleep(10000); }
catch (InterruptedException e) { e.printStackTrace(); }
Log.e("GoogleApiClient: %s", "onConnected");
app.getGoogleApiClient().unregisterConnectionCallbacks(this);
}
}
);
Log.e("GoogleApiClient: %s", "Connect");
googleApiClientUtility.connect();
Log.e("destination: %s", "main actvity");
startActivity(new Intent(SplashActivity.this, MainActivity.class));
this.finish();
나의 이해, 그것은 통과 직접 MainActivity 클래스로 이동합니다.
하지만 난 컴파일 때 주요 활동 클래스더욱 이상한 내 로그 고양이로 이동하기 전에, 그것은 10 초를 기다린 이유는 다음과 같은 내 로그 보여
GoogleApiClient: Connect
destination: main actvity <-- it should go to main activity here
... wait 10 secs....
GoogleApiClient: onConnected;
then after that it goes to main activity...
사람 이유를 설명 할 수 있습니까? 및 onConnected 콜백을 대기하지 않고 사용자가 다른 활동으로 이동하도록하려면 어떻게해야합니까?
잠을 제거하십시오. –
나는 대기 시간을 시뮬레이트하기 위해 잠을 사용합니다. 정말 그 때문입니까? – AnD
당신은 명시 적으로 활동을 10 초 동안 기다렸습니다. 예 –