Whenever I run the code for the very first time at my 1st app launched cycle
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(context)
.addApi(Drive.API)
.addScope(Drive.SCOPE_APPFOLDER) // required for App Folder sample
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
mGoogleApiClient.connect();
I can see the following account chooser.
However, if previous connect is success, and I run the same code again for first time at my 2nd app launched cycle.
The account chooser will not pop up again. GoogleApiClient
is going to use the account name, I choose in previous app launch cycle.
I wish to have my account chooser pop up every-time.
I came across How to Clear GoogleApiClient Default Account and Credentials
The proposed solution doesn't work for my case.
mGoogleApiClient.clearDefaultAccountAndReconnect()
If I had been connected for my previous app cycle, and I call the above code first time in my current app cycle, I will get the following exception.
java.lang.IllegalStateException: GoogleApiClient is not connected yet.
at com.google.android.gms.common.internal.zzx.zza(Unknown Source)
at com.google.android.gms.common.api.internal.zzj.clearDefaultAccountAndReconnect(Unknown Source)
The following code won't work either.
if (mGoogleApiClient.isConnected()) {
// No chance to execute this code, if you run this code during app launch.
mGoogleApiClient.clearDefaultAccountAndReconnect();
} else {
// No account chooser will pop up if you had been connected in previous app life cycle
mGoogleApiClient.connect();
}
May I know, how can I enforce GoogleApiClient to prompt account chooser UI each time I call connect?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…