-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain2Activity.java
92 lines (77 loc) · 2.9 KB
/
Main2Activity.java
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.example.user.instas;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
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.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
public class Main2Activity extends AppCompatActivity implements View.OnKeyListener {
Button b2;
Intent i2;
private FirebaseAuth f;
private EditText e1;
private EditText e2;
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
b2=(Button)findViewById(R.id.button2);
e1=(EditText) findViewById(R.id.editText);
e2=(EditText)findViewById(R.id.editText6);
f=FirebaseAuth.getInstance();
i2= new Intent(this,MainActivity.class);
mAuth = FirebaseAuth.getInstance();
e2.setOnKeyListener(this);
}
private void res()
{
String email=e1.getText().toString().trim();
String password=e2.getText().toString().trim();
f.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// # success, update UI with the signed-in user's information
Log.i("JIO", "createUserWithEmail:success");
Toast.makeText(Main2Activity.this, "Authentication Sucess.",
Toast.LENGTH_SHORT).show();
} else {
// If # fails, display a message to the user.
Log.i("JIO", "createUserWithEmail:failure", task.getException());
Toast.makeText(Main2Activity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// ...
}
});
}
@Override
public void onStart() {
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly.
}
@Override
public boolean onKey(View view, int i, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
(i == KeyEvent.KEYCODE_ENTER))
{
jai(view);
}
return false;
}
public void jai(View view)
{
res();
startActivity(i2);
}
}