0

我只想发送一封带有附件的电子邮件。我只是根据开发者网站完成了所有工作。

https://developer.android.com/training/sharing/send.html

它打开电子邮件意图选择器,但是当我单击选择器中的任何应用程序时,它不会打开任何应用程序来发送带有附件的邮件。我想在 Android Manifest 文件中添加的任何内容。

帮助更受欢迎。

我也从日志中收到消息:

    06-02 11:49:36.751: W/ContextImpl(16313): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:830 com.samsung.android.share.SShareLogging.insertLog:74 com.android.internal.app.ResolverActivity.onTargetSelected:1223 com.android.internal.app.ChooserActivity.onTargetSelected:386 com.android.internal.app.ResolverActivity.startSelected:1040 
    06-02 11:49:36.771: W/AudioPolicyIntefaceImpl(3069): Skipped to add effects on session 2024
4

2 回答 2

0

使用此代码,这可能对您有帮助

Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:" + "" + receiver_mail);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "body");

try {
startActivity(Intent.createChooser(emailIntent, "Send email using..."));
} 
catch (android.content.ActivityNotFoundException ex) 
{
Toast.makeText(ClusteringMinimaTest.this, "No email clients installed.", Toast.LENGTH_SHORT).show();
}
于 2016-06-02T06:03:22.123 回答
0

试试下面的代码。

       try { 
              final Intent emailIntent = new Intent(
                                     android.content.Intent.ACTION_SEND);
              emailIntent.setType("plain/text");
              emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                                     new String[] { "YOUR_RECIEPINTS" });
              emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                                     "YOUR_SUBJECT");
               if (URI != null) {
                         emailIntent.putExtra(Intent.EXTRA_STREAM, URI);
               }
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "YOUR_MESSAGE");

             this.startActivity(Intent.createChooser(emailIntent,
                                     "Sending email..."));

         } catch (Throwable t) {
                    Toast.makeText(this,
                                     "Request failed try again: " + t.toString(),
                                     Toast.LENGTH_LONG).show();
         }

如果它给出任何权限异常,则使用以下权限,

   <uses-permission android:name="android.permission.INTERNET" />
   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
于 2016-06-02T06:17:23.003 回答