-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWrongPasswordActivity.java
More file actions
84 lines (42 loc) · 2.04 KB
/
WrongPasswordActivity.java
File metadata and controls
84 lines (42 loc) · 2.04 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
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
import android.content.Intent;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
public class WrongPasswordActivity extends AppCompatActivity {
private static final int REQUEST_IMAGE_CAPTURE = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wrong_password);
// Add a click listener to the "Enter Password" button
findViewById(R.id.enter_password_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Get the password entered by the user
EditText passwordEditText = findViewById(R.id.password_edit_text);
String password = passwordEditText.getText().toString();
// Check if the entered password is correct
if (!password.equals("myPassword")) {
// If the password is incorrect, take a selfie and send it to info@jackisa.com
dispatchTakePictureIntent();
sendSelfieToEmail();
} else {
// If the password is correct, proceed to the next activity
Intent intent = new Intent(WrongPasswordActivity.this, HomeActivity.class);
startActivity(intent);
}
}
});
}
// Create an intent to take a picture
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
// Send the selfie to info@jackisa.com
private void sendSelfieToEmail() {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"info@jackisa.com"});