I've been trying run the app through the emulator in Android Studio but it keeps on crashing, I figured this may be because the startActivityForResult is deprecated. What should be the new format for this?
private void signIn() {
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
Here's the full activity:
public class MainActivity extends AppCompatActivity {
SignInButton signin;
private GoogleSignInClient mGoogleSignInClient;
static final int RC_SIGN_IN = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
requestGoogleSignIn();
signin.setOnClickListener(view -> signIn());
}
private void requestGoogleSignIn()
{
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
}
private void signIn() {
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
}
}