OnConnectionSuspended. How to check? When will this code be launched?

public class MainActivity extends Activity implements GoogleApiClient.ConnectionCallbacks { @Override public void onConnectionSuspended(int i) { Log.d(TAG, "onConnectionSuspended() called. Trying to reconnect."); sendToast("onConnectionSuspended() called. Trying to reconnect."); mGoogleApiClient.connect(); } [...] } 

I read the documentation: https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.ConnectionCallbacks.html

Based on what I read, I did a simple test in which I connected two peers in Quick Game. I disconnected the WiFi connection on one of them. I thought I was going to see a toast for onConnectionSuspended. Is there any way to encourage this toast to come for testing?

thanks

+8
android google-play-games
source share
1 answer

onConnectionSuspended is called when your application disconnects from the Google Play service package (not necessarily on the Internet). The callback is activated, for example, when you go to Settings> Applications> Google Play Services> Force Stop . Another example is to remove Google Play services. You will get onConnectionSuspended , and then onConnectionFailed in a couple of seconds (because the reconnection attempt failed).

Also do not call mGoogleApiClient.connect() from onConnectionSuspended(...) . Reconnection is automatic.

+17
source share

All Articles