-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForgotActivity.java
More file actions
54 lines (44 loc) · 2.01 KB
/
Copy pathForgotActivity.java
File metadata and controls
54 lines (44 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.example.foodiemenu;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
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 ForgotActivity extends AppCompatActivity {
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_forgot);
mAuth = FirebaseAuth.getInstance();
EditText emailText = findViewById(R.id.emailid);
Button forgotPasswordButton = findViewById(R.id.forgotp);
forgotPasswordButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = emailText.getText().toString();
if (TextUtils.isEmpty(email)) {
Toast.makeText(ForgotActivity.this, "Please enter your email", Toast.LENGTH_SHORT).show();
} else {
mAuth.sendPasswordResetEmail(email)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(ForgotActivity.this, "Password reset email sent", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(ForgotActivity.this, "Failed to send password reset email", Toast.LENGTH_SHORT).show();
}
}
});
}
}
});
}
}