Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法从我的应用程序发送电子邮件_Android - Fatal编程技术网

Android 无法从我的应用程序发送电子邮件

Android 无法从我的应用程序发送电子邮件,android,Android,我有一个要求,我需要从我的应用程序发送电子邮件,我使用下面的代码发送电子邮件 Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("Text/Plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[]{abc@gmail.com}); intent.putExtra(Intent.EXTRA_TEXT, "hello..");

我有一个要求,我需要从我的应用程序发送电子邮件,我使用下面的代码发送电子邮件

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("Text/Plain");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{abc@gmail.com});
    intent.putExtra(Intent.EXTRA_TEXT, "hello..");
    startActivity(Intent.createChooser(intent, email_chooser_title));
上面的代码启动电子邮件生成器。但当我按下发送按钮后,我可以看到一条祝酒词“messagesending”,但我的消息没有发送


请帮助我找出我在这方面做错了什么,或者让我知道是否有其他办法可以解决这个问题。。谢谢。

您正在用phone?测试您的应用程序?。。如果是,那么请确保您的后台服务已打开。karthik,是的,我正在电话上测试。我无法理解您的短语“确保您的后台服务处于打开状态”。。你能详细说明一下吗?这意味着你的手机的后台服务(同步)是开着还是关着。。如果关闭,您的应用程序将简单地发送消息,并等待后台服务启动。当后台服务启动时,它会发送邮件。如果你有三星安卓手机,那么进入设置->账户和同步->背景数据(启用/禁用)…你也可以查看我的博客
   Intent i = new Intent(Intent.ACTION_SEND);
    //i.setType("text/plain"); //use this line for testing in the emulator
    i.setType("message/rfc822") ; // use from live device
    i.putExtra(Intent.EXTRA_EMAIL, new String[]{"test@gmail.com"});
    i.putExtra(Intent.EXTRA_SUBJECT,"subject goes here");
    i.putExtra(Intent.EXTRA_TEXT,"body goes here");
    startActivity(Intent.createChooser(i, "Select email application."));