單擊按鈕時,我寫了一段代碼段來發送郵件。但是當我點擊發送郵件按鈕,我得到的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[] {"[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("");
}
};
}
我應該使用另一個類onClicklistener或者我可以在這個活動本身顯示郵件...
請確保您具有適當的權限 – Pentium10 2010-04-06 14:14:43
我應該添加除INTERNET權限之外的其他任何權限以發送郵件嗎? – 2010-04-07 05:28:34