我的电子邮件意图很好,因为它发布了电子邮件。我现在遇到一个问题,一旦我点击我的自定义模板上的“发送电子邮件”,它设置了GMail模板的“收件人”,“主题”和“邮件”字段,它加载正常,但是当我点击“发送”时GMail模板循环回自定义模板。如图所示:
这是我自定义的电子邮件模板:
点击“发送电子邮件”后,将加载Gmail模板:
一旦GMail模板的“发送”按钮被阻止,它就会循环回到自定义模板,并且它们会不断地相互循环。希望有人能让我知道如何阻止这种循环!
这是我在'onClick'中的意图的代码:
package com.example.flybase2;
import android.app.Activity;
import android.app.Dialog;
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;
import android.widget.TextView;
public class ContactsEmail extends Activity implements OnClickListener{
String emailPassed;
String emailAdd;
String emailSub;
String emailMess;
EditText setEmailAddress;
EditText setEmailSubject;
EditText setEmailMessage;
Button btnSendEmail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.emaillayout);
Bundle extras = getIntent().getExtras();
if (extras != null) {
emailPassed = extras.getString("passedEmailAdd");
}
setEmailAddress = (EditText) findViewById (R.id.inputEmailAddress);
setEmailAddress.setText(emailPassed);
setEmailSubject = (EditText) findViewById (R.id.inputEmailSubject);
setEmailMessage = (EditText) findViewById (R.id.inputEmailMessage);
btnSendEmail = (Button)findViewById(R.id.btnSendEmail);
btnSendEmail.setOnClickListener(this);
}
@Override
public void onClick(View sendEmailClick) {
emailAdd = setEmailAddress.getText().toString();
emailSub = setEmailSubject.getText().toString();
emailMess = setEmailMessage.getText().toString();
Intent sendEmailIntent = new Intent(Intent.ACTION_SEND);
sendEmailIntent.setType("plain/text");
sendEmailIntent.putExtra(Intent.EXTRA_EMAIL,new String[] {emailAdd});
sendEmailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSub);
sendEmailIntent.putExtra(Intent.EXTRA_TEXT, emailMess);
startActivity(Intent.createChooser(sendEmailIntent, "Send mail..."));
}
}
答案 0 :(得分:0)
您似乎只想在finish()
结束时致电onClick()
。这将关闭ContactsEmail,允许用户从GMail应用程序返回更有用的Activity。