Я написал небольшое приложение для отправки электронного письма с помощью Action_Send.Когда я запускаю упражнение, нажимая кнопку отправки, я получаю опцию отправки электронного письма с помощью приложения Gmail или Hotmail (hotmail + SEVEN).Если я выберу 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();
}
}