我得到一个错误"没有应用程序可以执行此操作"在发送一个电子邮件 [英] I get an error" No application can perform this action" while sending an email
本文介绍了我得到一个错误"没有应用程序可以执行此操作"在发送一个电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是code,除了没有应用程序对一切行之有效的可以执行此操作error..Please让我知道什么是在code中的错误。
公共无效发送(查看按钮){
//请点击这里处理
最终的EditText日期=(EditText上)findViewById(R.id.editText1);
。字符串DA = date.getText()的toString(); 最终的EditText手机=(EditText上)findViewById(R.id.editText2);
。字符串的pH = phone.getText()的toString(); 最终的EditText铭牌=(EditText上)findViewById(R.id.editText3);
字符串NP = nameplate.getText()的toString()。 最终的EditText问题=(EditText上)findViewById(R.id.editText4);
。字符串I = issue.getText()的toString(); StringBuilder的S =新的StringBuilder(100);
s.append(DA);
s.append(。);
s.append(PH);
s.append(。);
s.append(NP);
s.append(。);
s.append(ⅰ); 串ST = s.toString();
意图emailIntent =新意图(android.content.Intent.ACTION_SEND);
//emailIntent.setType(\"plain/text);
// startActivity(emailIntent);
startActivity(Intent.createChooser(emailIntent,送你的电子邮件:)); 意图emailIntentt =新意图(android.content.Intent.ACTION_SEND); 字符串aEmailList [] = {shreyas.tallani@gmail.com};
emailIntentt.putExtra(android.content.Intent.EXTRA_EMAIL,aEmailList);
//emailIntentt.putExtra(android.content.Intent.EXTRA_CC,aEmailCCList);
//emailIntentt.putExtra(android.content.Intent.EXTRA_BCC,aEmailBCCList); emailIntentt.putExtra(android.content.Intent.EXTRA_SUBJECT,反馈); emailIntentt.setType(信息/ RFC822);
emailIntentt.putExtra(android.content.Intent.EXTRA_TEXT,ST);
startActivityForResult(emailIntentt,REQUEST_SEND_MAIL);
}
公共静态最终诠释REQUEST_SEND_MAIL = 1; 公共无效的onActivityResult(INT申请code,INT结果code,意图数据){ 开关(要求code){
案例REQUEST_SEND_MAIL:
//当请求发送邮件的回报
如果(结果code == Activity.RESULT_OK){
Toast.makeText(这一点,消息发送成功,Toast.LENGTH_SHORT).show(); }其他{
Toast.makeText(这一点,对不起,Toast.LENGTH_SHORT).show();
} }}
解决方案
您有 startActivity()
和 startActivityForResult
!您需要一个。这就是为什么第一个意图被炒鱿鱼,也没有应用程序来抓住它。
试试这个:
意图emailIntent =新意图(android.content.Intent.ACTION_SEND);
字符串aEmailList [] = {shreyas.tallani@gmail.com};emailIntent.setType(纯/文);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,aEmailList);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,反馈);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,ST);startActivityForResult(emailIntent,REQUEST_SEND_MAIL);
Here is the code, everythin works well except the no application can perform this action "error..Please let me know what is the mistake in the code.
public void sends(View button) {
// Do click handling here
final EditText date = (EditText) findViewById(R.id.editText1);
String da = date.getText().toString();
final EditText phone = (EditText) findViewById(R.id.editText2);
String ph = phone.getText().toString();
final EditText nameplate = (EditText) findViewById(R.id.editText3);
String np = nameplate.getText().toString();
final EditText issue = (EditText) findViewById(R.id.editText4);
String i = issue.getText().toString();
StringBuilder s= new StringBuilder(100);
s.append(da);
s.append(". ");
s.append(ph);
s.append(". ");
s.append(np);
s.append(". ");
s.append(i);
String st=s.toString();
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
//emailIntent.setType("plain/text");
//startActivity(emailIntent);
startActivity(Intent.createChooser(emailIntent, "Send your email in:"));
Intent emailIntentt= new Intent(android.content.Intent.ACTION_SEND);
String aEmailList[] = { "shreyas.tallani@gmail.com" };
emailIntentt.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
//emailIntentt.putExtra(android.content.Intent.EXTRA_CC, aEmailCCList);
//emailIntentt.putExtra(android.content.Intent.EXTRA_BCC, aEmailBCCList);
emailIntentt.putExtra(android.content.Intent.EXTRA_SUBJECT, "Feedback");
emailIntentt.setType("message/rfc822");
emailIntentt.putExtra(android.content.Intent.EXTRA_TEXT, st);
startActivityForResult(emailIntentt, REQUEST_SEND_MAIL);
}
public static final int REQUEST_SEND_MAIL = 1;
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_SEND_MAIL:
// When the request to send mail returns
if (resultCode == Activity.RESULT_OK) {
Toast.makeText(this, "message successfully sent", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "sorry", Toast.LENGTH_SHORT).show();
}
}}
解决方案
You have startActivity()
and startActivityForResult
!!! You need one. That's why the first intent gets fired and there is no app to catch it.
Try this:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String aEmailList[] = { "shreyas.tallani@gmail.com" };
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Feedback");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, st);
startActivityForResult(emailIntent, REQUEST_SEND_MAIL);
这篇关于我得到一个错误"没有应用程序可以执行此操作"在发送一个电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文