Iv'e tried creating some kind of password reminder that sends the password to the user email. instead whenever I try sending this mail through the app I'm only get to the send SMS page. I'm using the latest android studio version.
public void ForgetPasswordEvent (View view) {
//AlertDialog recovery = new AlertDialog();
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Please enter your registered email");
// Set up the input
final EditText input = new EditText(this);
// Specify the type of input expected;
input.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
builder.setView(input);
// Set up the buttons
builder.setPositiveButton("Send", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
m_Text= input.getText().toString();
Log.i("Send email", "");
// String[] TO = {m_Text.toString()};
String[] TO = {"erez@manageyourtrip.com"};
String[] CC = {"erez@manageyourtrip.com"};
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "MYT GuideApp password recovery");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Your password is 123456");
try {
startActivity(createChooser(emailIntent, "Send mail..."));
finish();
Log.i("Finished sending email", "");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this,
"There is no email client installed.", Toast.LENGTH_SHORT).show();
}
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();