-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActivityEmail.java
47 lines (33 loc) · 1.48 KB
/
ActivityEmail.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
package com.example.appmenu;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class ActivityEmail extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_email);
}
public void enviar (View view){
EditText correo = findViewById(R.id.editEmail);
EditText asunto = findViewById(R.id.editAsunto);
EditText mensaje = findViewById(R.id.editTextTextMultiLine);
String enviarcorreo = correo.getText().toString();
String enviarasunto = asunto.getText().toString();
String enviarmensaje = mensaje.getText().toString();
// Defino mi Intent y hago uso del objeto ACTION_SEND
Intent intent = new Intent(Intent.ACTION_SEND);
// Defino los Strings Email, Asunto y Mensaje con la función putExtra
intent.putExtra(Intent.EXTRA_EMAIL,
new String[] { enviarcorreo });
intent.putExtra(Intent.EXTRA_SUBJECT, enviarasunto);
intent.putExtra(Intent.EXTRA_TEXT, enviarmensaje);
// Establezco el tipo de Intent
intent.setType("message/rfc822");
// Lanzo el selector de cliente de Correo
startActivity( Intent.createChooser(intent,"Enviar:"));
}
}