I have a simple contact form app and what I want to accomplish is once the form is filled out, I want the info sent directly to my gmail after pressing the send button. I do not want the "Complete action using" to pop up. Just sent directly to my gmail. I am currently using an intent to make the info to be sent. Is there some other type of method I could use to have the info directly sent to my gmail?
Here is my MainActivity.java file:
package com.qnutapps.contactform1;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener{
/** Called when the activity is first created. */
EditText etname, etphone, etemail, etadd;
Button send;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etname = (EditText) findViewById (R.id.etName);
etphone = (EditText) findViewById (R.id.etPhone);
etemail = (EditText) findViewById (R.id.etEmail);
etadd = (EditText) findViewById (R.id.etAdd);
send = (Button) findViewById (R.id.send);
send.setOnClickListener(this);
}
public void onClick(View Arg0) {
//if(etname.getText().toString().length()==0)
//{
//etname.setError( "Please Enter Your Name" );
//}
//else if(etphone.getText().toString().length()==0)
//{
//etphone.setError( "Please Enter Your Phone #" );
//}
//else if(etemail.getText().toString().length()==0)
//{
//etemail.setError( "Please Enter Your E-mail" );
//}
//else if(etadd.getText().toString().length()==0)
//{
//etadd.setError( "Vul uw bericht in" );
//}
//else if(subject.getSelectedItemPosition()==0)
//{
//Toast.makeText(MainActivity.this,"Please select the Subject",Toast.LENGTH_SHORT).show();
//}
//else
//{
Toast.makeText(getApplicationContext(), "Sending E-Mail", Toast.LENGTH_SHORT).show(); //Sends message after button is clicked
StringBuilder body = new StringBuilder();
body.append("Name: "+etname.getText().toString());
body.append("\nPhone: "+etphone.getText().toString());
body.append("\nEmail: "+etemail.getText().toString());
body.append("\nAdditional Information: "+etadd.getText().toString());
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"marketing.otwist@gmail.com"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Customer Details");
emailIntent.putExtra(Intent.EXTRA_TEXT, body.toString());
emailIntent.setType("message/rfc822"); //can also use "message/rfc822"
startActivity(emailIntent);
}
}
//}