Created
October 7, 2019 18:37
-
-
Save bariskarapinar/ef030104fd3a875d4fce9fc8aae133e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.firebaseauthproject; | |
import android.annotation.SuppressLint; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.v7.app.AppCompatActivity; | |
import android.text.TextUtils; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.EditText; | |
import android.widget.Toast; | |
import com.google.android.gms.tasks.OnCompleteListener; | |
import com.google.android.gms.tasks.Task; | |
import com.google.firebase.auth.FirebaseAuth; | |
public class ResetPasswordActivity extends AppCompatActivity { | |
private EditText inputEmail; | |
private Button btnReset; | |
private FirebaseAuth auth; | |
@SuppressLint("WrongViewCast") | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_reset_password); | |
inputEmail = (EditText) findViewById(R.id.EditTextSurname); | |
btnReset = (Button) findViewById(R.id.btn_reset_password); | |
auth = FirebaseAuth.getInstance(); | |
btnReset.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
String email = inputEmail.getText().toString().trim(); | |
if (TextUtils.isEmpty(email)) { | |
Toast.makeText(getApplication(), "Enter your mail address", Toast.LENGTH_SHORT).show(); | |
return; | |
} | |
auth.sendPasswordResetEmail(email) | |
.addOnCompleteListener(new OnCompleteListener<Void>() { | |
@Override | |
public void onComplete(@NonNull Task<Void> task) { | |
if (task.isSuccessful()) { | |
Toast.makeText(ResetPasswordActivity.this, "We send you an e-mail", Toast.LENGTH_SHORT).show(); | |
} else { | |
Toast.makeText(ResetPasswordActivity.this, "Error", Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); | |
} | |
}); | |
} | |
public void NavigateSignUp(View v) { | |
Intent inent = new Intent(this, SignUpActivity.class); | |
startActivity(inent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment