本文介绍了在gmail Android应用程序中发送带有附件的电子邮件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试发送带有附件的电子邮件。
也只寻找电子邮件客户端回复。
I have been trying to send an email with attachment.Also looking for only email clients to respond.
我已经遵循这个链接。
以下是我的代码执行相同的
Below is my code which does the same
Intent intent = new Intent(Intent.ACTION_SENDTO);
// Set MIME type to email message to avoid other non-email applications showing up
intent.setData(Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_EMAIL, to);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, body);
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
这样做,我在选择器对话框中获得了Gmail和Android电子邮件客户端。
当我点击gmail客户端以后出现错误。
Doing this, i get the gmail and the android email client in the chooser dialog.When i click on gmail client following error comes. Same is working fine with the android email client.
01-08 13:04:50.385: E/AndroidRuntime(13369): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.gm/com.google.android.gm.ComposeActivityGmail}: java.lang.NullPointerException
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.os.Looper.loop(Looper.java:137)
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.app.ActivityThread.main(ActivityThread.java:5103)
01-08 13:04:50.385: E/AndroidRuntime(13369): at java.lang.reflect.Method.invokeNative(Native Method)
01-08 13:04:50.385: E/AndroidRuntime(13369): at java.lang.reflect.Method.invoke(Method.java:525)
01-08 13:04:50.385: E/AndroidRuntime(13369): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
01-08 13:04:50.385: E/AndroidRuntime(13369): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-08 13:04:50.385: E/AndroidRuntime(13369): at dalvik.system.NativeStart.main(Native Method)
01-08 13:04:50.385: E/AndroidRuntime(13369): Caused by: java.lang.NullPointerException
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.content.ContentResolver.acquireExistingProvider(ContentResolver.java:1116)
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.content.ContentResolver.getType(ContentResolver.java:257)
01-08 13:04:50.385: E/AndroidRuntime(13369): at com.android.mail.compose.AttachmentsView.m(SourceFile:217)
01-08 13:04:50.385: E/AndroidRuntime(13369): at com.android.mail.compose.ComposeActivity.a(SourceFile:664)
01-08 13:04:50.385: E/AndroidRuntime(13369): at com.android.mail.compose.ComposeActivity.zR(SourceFile:575)
01-08 13:04:50.385: E/AndroidRuntime(13369): at com.android.mail.compose.ComposeActivity.onCreate(SourceFile:437)
01-08 13:04:50.385: E/AndroidRuntime(13369): at com.google.android.gm.ComposeActivityGmail.onCreate(SourceFile:54)
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.app.Activity.performCreate(Activity.java:5133)
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
01-08 13:04:50.385: E/AndroidRuntime(13369): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
01-08 13:04:50.385: E/AndroidRuntime(13369): ... 11 more
欢呼声,
Saurav
cheers,Saurav
推荐答案
请看看
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
// emailIntent.putExtra(android.content.Intent.EXTRA_BCC, new String[]{etEmail.getText().toString()});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getResources().getString(R.string.feedback_for)+"an interesting place");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, etComment.getText().toString()+"\n\n"+getResources().getString(R.string.rating)+rbRating.getRating()+"\n"+getResources().getString(R.string.my_contact_number)+etPhoneNumber.getText().toString());
startActivity(Intent.createChooser(emailIntent, getResources
().getString(R.string.chooser_send_feedback)));
请关注我的博客,这将有助于您
please follow my blog, it will help you
这篇关于在gmail Android应用程序中发送带有附件的电子邮件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!