未找到活动尝试发送邮件时出现异常

时间:2010-04-06 10:34:29

标签: android

我编写了一个代码片段,用于在单击按钮时发送邮件。但是当我点击发送邮件按钮时,我在logcat中得到一个ActivityNotFound异常......这是代码...

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[] {"helpline@xyz.com" });
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("");


}
};
} 

我应该为onClicklistener使用另一个类,还是可以在此活动中显示邮件...

1 个答案:

答案 0 :(得分:0)

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

尝试将类型切换为: 的setType( “消息/ RFC822”);