• 1000 как я могу завершить действие, нажав кнопку возврата
это часть моего кода
@Override
protected void onStart() {
super.onStart();
auth.addAuthStateListener(listener);
}
@Override
protected void onStop() {
if (listener != null)
auth.removeAuthStateListener(listener);
disposable.clear();
super.onStop();
}
private void Init() {
//Init Firebase
auth = FirebaseAuth.getInstance();
db = FirebaseDatabase.getInstance();
users = db.getReference(Common.user_rider_tbl);
providers = Arrays.asList(new AuthUI.IdpConfig.PhoneBuilder().build(),
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build());
listener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
//Account is already logged in
CheckUserFromFirebase(user);
} else {
SignWithPhone();
}
}
};
}
private void SignWithPhone() {
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setTheme(R.style.LoginTheme)
.setIsSmartLockEnabled(false)
.setLogo(R.drawable.logo)
.setAvailableProviders(providers)
.build(),
APP_REQUEST_CODE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == APP_REQUEST_CODE) {
IdpResponse response = IdpResponse.fromResultIntent(data);
providerType = response.getProviderType();
if (resultCode == RESULT_OK) {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
} else {
if (response == null) {
// User pressed back button. NOTE: This is where the back action is
//taken care of
finish();
}
if (Objects.requireNonNull(response.getError()).getErrorCode() == ErrorCodes.NO_NETWORK) {
//Show No Internet Notification
return;
}
if (response.getError().getErrorCode() == ErrorCodes.UNKNOWN_ERROR)
{
Log.i(TAG, "EEERRROORRRR: "+ response.getError().getErrorCode());
return;
}
Log.i(TAG, "EEERRROORRRR: "+ response.getError().getErrorCode());
}
}
}
не могли бы вы мне помочь, пожалуйста