2
我编写了一个使用Action_Send发送电子邮件的小应用程序。 当我通过按发送按钮开始活动时,我可以选择使用Gmail或Hotmail应用程序(hotmail + SEVEN)发送电子邮件。 如果我选择Gmail,则该活动已强制关闭。 如果我选择Hotmail,用户输入的电子邮件地址显示为NULL;电子邮件使用Gmail和电子邮件地址的活动崩溃在hotmail上显示为NULL
我已经发布了下面的代码。我究竟做错了什么?
package android.development.tutorial;
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;
public class EmailActivity extends Activity implements View.OnClickListener
{
String receipantAddress, subject, message;
EditText edtReceipantAddress, edtSubject, edtMessage;
Button btnSend;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.email);
initUIComponents();
}
private void initUIComponents()
{
this.edtReceipantAddress= (EditText) findViewById(R.id.edtReceipantAddress);
this.edtSubject = (EditText) findViewById(R.id.edtSubject);
this.edtMessage = (EditText) findViewById(R.id.edtMessage);
this.btnSend = (Button) findViewById(R.id.btnSend);
btnSend.setOnClickListener(this);
}
private void setEmailParameters()
{
this.receipantAddress = this.edtReceipantAddress.getText().toString();
this.subject = this.edtSubject.getText().toString();
this.message = this.edtMessage.getText().toString();
}
public void onClick(View v)
{
String emailAddresses []= {this.receipantAddress};
setEmailParameters();
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,emailAddresses);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, this.subject);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, this.message);
this.startActivity(emailIntent);
}
protected void onPause()
{
super.onPause();
EmailActivity.this.finish();
}
}
+1 - 第二组眼睛总是有帮助。这就是我喜欢结对编程的原因。 – 2011-12-29 13:52:30
@MatNadrofsky Thanx :) – 2011-12-29 14:02:56
你保存了一天,帕雷什!完全忽略了这个:) – 2011-12-29 14:50:18