Я пытаюсь отправить электронное письмо с несколькими текстовыми полями, введенными пользователем, используя почтовый клиент из приложения.
Android не открывает почтовый клиент при запуске приложения через эмулятор или через мойAndroid-устройство.
Я очень увлекаюсь этим и играю в раунд.
public class send_page extends AppCompatActivity {
Button sendbutton;
EditText textdescribe;
EditText textcause;
EditText textcorrective;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_send_page);
Button sendbutton = (Button) findViewById(R.id.send_button);
textdescribe = (EditText) findViewById(R.id.describe);
textcause = (EditText) findViewById(R.id.cause);
textcorrective = (EditText) findViewById(R.id.corrective_actions);
sendbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String[] TO = {"email address"};
String[] SUBJECT = {"Near Miss Report"};
String description = textdescribe.getText().toString();
String causefactor = textcause.getText().toString();
String action = textcorrective.getText().toString();
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.setData(Uri.parse("mailto:"));
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"email address"});
email.putExtra(Intent.EXTRA_TEXT, description);
email.putExtra(Intent.EXTRA_TEXT, causefactor);
email.putExtra(Intent.EXTRA_TEXT, action);
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
}
});
}
}