Android 使用gmail的电子邮件活动崩溃,hotmail上的电子邮件地址显示为空
我编写了一个小应用程序,使用Action_send发送电子邮件。 当我按下发送按钮开始活动时,我可以选择使用Gmail或Hotmail应用程序(Hotmail+SEVEN)发送电子邮件。 如果我选择Gmail,活动将强制关闭。 如果选择Hotmail,则用户输入的电子邮件地址显示为空 我已经把代码贴在下面了。我做错了什么Android 使用gmail的电子邮件活动崩溃,hotmail上的电子邮件地址显示为空,android,email,Android,Email,我编写了一个小应用程序,使用Action_send发送电子邮件。 当我按下发送按钮开始活动时,我可以选择使用Gmail或Hotmail应用程序(Hotmail+SEVEN)发送电子邮件。 如果我选择Gmail,活动将强制关闭。 如果选择Hotmail,则用户输入的电子邮件地址显示为空 我已经把代码贴在下面了。我做错了什么 package android.development.tutorial; import android.app.Activity; import android.conte
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();
}
}
这是一个愚蠢的错误:
String emailAddresses []= {this.receipantAddress};
setEmailParameters();
它应该如下所示,因为您正在setEmailParameters()中进行参数设置
+一秒钟的眼睛总是有帮助的。这就是为什么我喜欢结对编程。你救了我,帕雷什!完全忽略了这一点:)::)当我们的作品超负荷时,有时会发生这种情况:)
setEmailParameters();
String emailAddresses []= {this.receipantAddress};