I have been trying to send an email with attachment. Also looking for only email clients to respond.
I have followed this link Send Email Intent.
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);
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
cheers, Saurav