Android - 得到错误“无应用程序可以执行此操作”在试图发送电子邮件? [英] Android - getting an error "no application can perform this action" while trying to send an email?

查看:327
本文介绍了Android - 得到错误“无应用程序可以执行此操作”在试图发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个应用程序,我将向我的客户提供反馈功能。为了实现这一点,我创建了一个小对话框,用户可以在其中输入反馈并将其发送到我的邮件ID。我尝试了一些我在互联网上发现的代码片段,但是每当我尝试从仿真器或实际设备发送电子邮件时,我都会发现错误无应用程序可以执行此操作。

I am making an app in which i am going to provide a feedback feature to my customers. To acheive this i have created a small dialogue box where user can input there feedback and send it to my mail ID. I tried some code snippets which i found on internet but whenever i try to send an email from emulator or actual device, i am gettig an error "No Application can perform this action".

这是我的代码: -

Here is my code :-

public void emailDialog()
{
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
    alertDialog.setTitle("Feedback");
    alertDialog.setMessage("Please tell us that what you feel about our product. If you are facing any problem or found any bug then please report to us. Your review is important to us. Thanks!!");
    final EditText input = new EditText(this);
    input.setLines(8);
    alertDialog.setView(input);
    alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();
            String address = "varundroid@gmail.com";
            String subject = "FeedBack";
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, address);
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, value);
            CompleteTaskManager.this.startActivity(Intent.createChooser(emailIntent, "Send Email.."));
        }
    });
    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int whichButton) {
        // Canceled.
      }
    });
alertDialog.show();
}

请帮助。

推荐答案

我想你需要设置intent对象的类型。你可以尝试以下

I think you need to set the type of the intent object. Can you try the following

emailIntent.setType("message/rfc822");

emailIntent.setType("text/plain");

这篇关于Android - 得到错误“无应用程序可以执行此操作”在试图发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆