I'm having an issue with my application. The purpose of the app is to collect data and submit the data form using javamail to a specified email address. when the user clicks the button, they should receive a prompt to select an email client, however I am not getting this prompt when I test it. Can someone tell me what I am missing?
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
public class SubmitForm extends Activity implements View.OnClickListener {
private Intent emailIntent;
EditText personsFirstName, personsLastName, personsEmail, personsPhone, comments, vehicleModel;
Spinner vehicleYear, vehicleMake, serviceTime, serviceNeeded;
TextView serviceDate;
String fname, lname, emailAdd, phoneNumber, vehicleYears, vehicleModeltrim, vehicleManu, serviceAppointment, serviceAppointmentTime, serviceTypeNeeded, extraComments;
Button sendEmail;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.service);
initializeVars();
sendEmail.setOnClickListener(this);
}
private void initializeVars() {
// TODO Auto-generated method stub
personsFirstName = (EditText) findViewById(R.id.firstName);
personsLastName = (EditText) findViewById(R.id.lastName);
personsEmail = (EditText) findViewById(R.id.Email);
personsPhone = (EditText) findViewById(R.id.PhoneNumber);
vehicleYear = (Spinner) findViewById(R.id.sYear);
vehicleMake = (Spinner) findViewById(R.id.sMake);
vehicleModel = (EditText) findViewById(R.id.Model);
serviceDate = (TextView) findViewById(R.id.Model);
serviceTime = (Spinner) findViewById(R.id.sTime);
serviceNeeded = (Spinner) findViewById(R.id.sNeeded);
comments = (EditText) findViewById(R.id.eComments);
sendEmail = (Button) findViewById(R.id.bSubmit);
}
public void onClick(View v) {
// TODO Auto-generated method stub
convertToString();
String emailaddress[] = { emailAdd };
String message = "Please Review the following"
+ '\n' + " "
+ '\n' + "First Name: " + fname
+ '\n' + "Last Name: " + lname
+ '\n' + "Email :" + emailAdd
+ '\n' + "Phone Number: " + phoneNumber
+ '\n' + "Vechile Year: " + vehicleYears
+ '\n' + "Vehicle Make: " + vehicleManu
+ '\n' + "Vehicle Model: " + vehicleModeltrim
+ '\n' + "Requested Service Date: " + serviceAppointment
+ '\n' + "Requested Service Time: " + serviceAppointmentTime
+ '\n' + "Service Needed: " + serviceTypeNeeded
+ '\n' + "Comments: " + extraComments;
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"test@someemail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailaddress);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Schedule Service Request");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(emailIntent, "Please select Email Client"));
}
private void convertToString() {
// TODO Auto-generated method stub
fname = personsFirstName.getText().toString();
lname = personsLastName.getText().toString();
emailAdd = personsEmail.getText().toString();
phoneNumber = personsPhone.getText().toString();
//vehicleYears = vehicleYear.getText().toString();
vehicleYears = (String) vehicleYear.getAdapter().getItem(RESULT_OK);
//vehicleManu = vehicleMake.getText().toString();
vehicleManu = (String) vehicleMake.getAdapter().getItem(RESULT_OK);
vehicleModeltrim = vehicleModel.getText().toString();
serviceAppointment = serviceDate.getText().toString();
serviceAppointmentTime = (String) serviceTime.getAdapter().getItem(RESULT_OK);
//serviceTypeNeeded = serviceNeeded.getText().toString();
serviceTypeNeeded = (String) serviceNeeded.getAdapter().getItem(RESULT_OK);
extraComments = comments.getText().toString();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
finish();
}
}