tags:

views:

297

answers:

1

Hi,

I have written a code snippet to send mail when a button is clicked. But when i click the send mail button i am getting an ActivityNotFound exception in the logcat... Here's the code...

public class appointments extends Activity {

List<Strings> appnt=new ArrayList<Strings>();
ArrayAdapter<Strings> adapter=null;
EditText name=null;
EditText phone=null;
Date date=null;
Spinner spinner=null;
EditText make=null;
EditText miles=null;



@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
name=(EditText)findViewById(R.id.nametext);
phone=(EditText)findViewById(R.id.phonetext);
make=(EditText)findViewById(R.id.maketext);
miles=(EditText)findViewById(R.id.miles);



Button mail=(Button)findViewById(R.id.email);
mail.setOnClickListener(onMail);

Button reset=(Button)findViewById(R.id.reset);
reset.setOnClickListener(onReset);


Spinner hubSpinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter adapter = ArrayAdapter.createFromResource( this, R.array.services , android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
hubSpinner.setAdapter(adapter);

}
private View.OnClickListener onMail=new View.OnClickListener() {
public void onClick(View v)
{
Strings r=new Strings();
r.setName(name.getText().toString());
r.setPhone(phone.getText().toString());
r.setMake(make.getText().toString());
r.setMiles(miles.getText().toString());
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"[email protected]" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,r.getServices());
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, r.getName());
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, r.getMake());
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, r.getMiles());
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
};
private View.OnClickListener onReset=new View.OnClickListener() {
public void onClick(View v)
{

name.setText("");
phone.setText("");
make.setText("");
miles.setText("");


}
};
} 

Should i use another class for onClicklistener or can i display the mail in this activity itself...

A: 

http://www.openintents.org/en/node/121

Try switching the type to: setType("message/rfc822");

BZ
after executing the project when i click send mail there is an error in the emulator that NO APPLICATIONS CAN PERFORM THIS ACTION...Can you tell me what the error is??? should i declare the onClick on the button to send mail in a different class???
Rahul Varma