how to user open app without signin always, when user not logout.. I'm already using sharedpreff but still request login
this code for login
private void handleSignInResult(GoogleSignInResult result) {
Log.d("Hasil", "handleSignInResult:" + result.isSuccess());
Log.d("Hasil", "handleSignInResult:" + result.toString());
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
GoogleSignInAccount acct = result.getSignInAccount();
String nama = acct.getDisplayName();
String email = acct.getEmail();
String id = acct.getId();
String foto = String.valueOf(acct.getPhotoUrl());
session.createLoginSession(id,nama,email,foto);
SharedPrefApp sharedPref;
sharedPref = SharedPrefApp.getInstance();
sharedPref.saveISLogged_IN(this, true);//add this on user sucessful login
Intent i = new Intent(getApplicationContext(),WelcomeActivity.class);
startActivity(i);
finish();
} else {
Snackbar.make(((ViewGroup) findViewById(android.R.id.content)).getChildAt(0), "GAGAL LOGIN", Snackbar.LENGTH_SHORT).show();
}
}
答案 0 :(得分:0)
Working for me!
mGoogleApiClient.clearDefaultAccountAndReconnect();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
Make sure mGoogleApiClient not null