I am making a form that will be sent by email, I have already created the email from gmail to use in the application, I have already imported the necessary libraries, I have added the permissions in Manifest, the code does not display errors but also does not send the e- mail address. hereisthelayoutoftheformcalledrequests:
<?xmlversion="1.0" encoding="utf-8"?>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="To"
android:textColor="@android:color/white"
/>
<EditText
android:id="@+id/etTO"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:background="@android:color/darker_gray"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subject"
android:textColor="@android:color/white"
/>
<EditText
android:id="@+id/etSubject"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:textColor="@android:color/white"
/>
<EditText
android:id="@+id/etMsg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:inputType="textMultiLine"
android:lines="5"
android:background="@android:color/darker_gray"
/>
<Button
android:id="@+id/send_email_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Send"
/>
My activity e-mail:
public class Send_email extends MainActivity {
Button btnSend;
EditText To;
EditText Subject;
EditText Message;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_send_email);
To = (EditText) findViewById(R.id.etTO);
Subject = (EditText) findViewById(R.id.etSubject);
Message = (EditText) findViewById(R.id.etMsg);
btnSend = (Button) findViewById(R.id.send_email_button);
btnSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String to = To.getText().toString();
String subject = Subject.getText().toString();
String message = Message.getText().toString();
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Select Email Client"));
}
});
}
When emulating the application on the cell phone and opening the form, it's as if you did not even have the code running, just fill in the fields. Can anyone tell me what I'm doing wrong or missing for my code to work?