How do I integrate it? I want it so when the user first launches the app, it presents them with that pop up windows that gives you all your Google accounts and let's you choose one.
I have already followed this doc which led to no success and spent 4 hours looking on the web for solutions and all are either just as confusing or just something else entirely.
My code looks like this:
public class MainActivity extends AppCompatActivity {
private static final int RC_SIGN_IN = 9001;
TextView timerText;
Button startBtn, stopBtn;
int secs = 0, mins = 0, hours = 0;
CountDownTimer cdt;
long time = (long) 4.32e+7;
AlertDialog.Builder builder;
GoogleSignInClient mGoogleSignInClient;
FirebaseAuth auth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
auth = FirebaseAuth.getInstance();
builder = new AlertDialog.Builder(this);
timerText = findViewById(R.id.timerText);
startBtn = findViewById(R.id.buttonStart);
stopBtn = findViewById(R.id.stopButton);
stopBtn.setEnabled(false);
stopBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pauseTimer();
}
});
startBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startTimer();
}
});
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken("858032803571-gjihu12q7qejghlaesak59el15muqfgd.apps.googleusercontent.com")
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
checkLogIn();
}
void checkLogIn(){
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
if(account == null){
}
else{
signIn();
}
}
private void signIn() {
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
handleSignInResult(task);
}
}
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
} catch (ApiException e) {
}
}
/*
Check if the user is currently signed in with Google, if not, ask them to sign in.
If the user is in fact, signed in, the app will use the data from the users Google account.
*/
public void onStart(){
super.onStart();
checkLogIn();
}
.
.
.
.
}