Mögliches Duplikat:
wie man mehrere Dateien an einen E-Mail-Client in Android anhängt.
Hallo,
Ich kann eine E-Mail mit mehreren Anhängen nicht versenden.
Hier ist der Code, den ich im Internet und in Tutorials gefunden habe:
String[] mArray = getResources().getStringArray(R.array.pdf_entries);
int i = 0;
Intent theIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
theIntent.setType("application/pdf");
ArrayList<Uri> uris = new ArrayList<Uri>();
for (String file : mArray) {
if (booleans[i]) {
File fileIn = new File("/sdcard/mydir/"+file+".pdf");
Uri u = Uri.fromFile(fileIn);
Log.i("","** add: "+u);
uris.add(u);
}
i++;
}
theIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
startActivity(Intent.createChooser(theIntent,"Select email application."));
Aber ich bekomme immer diesen Fehler:
04-19 20:25:03.340: WARN/Bundle(5826): Key android.intent.extra.STREAM expected Parcelable but value was a java.util.ArrayList. The default value <null> was returned.
04-19 20:25:03.356: WARN/Bundle(5826): Attempt to cast generated internal exception:
04-19 20:25:03.356: WARN/Bundle(5826): java.lang.ClassCastException: java.util.ArrayList
04-19 20:25:03.356: WARN/Bundle(5826): at android.os.Bundle.getParcelable(Bundle.java:1106)
04-19 20:25:03.356: WARN/Bundle(5826): at android.content.Intent.getParcelableExtra(Intent.java:3396)
04-19 20:25:03.356: WARN/Bundle(5826): at com.android.email.activity.MessageCompose.initFromIntent(MessageCompose.java:1306)
04-19 20:25:03.356: WARN/Bundle(5826): at com.android.email.activity.MessageCompose.onCreate(MessageCompose.java:334)
04-19 20:25:03.356: WARN/Bundle(5826): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-19 20:25:03.356: WARN/Bundle(5826): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-19 20:25:03.356: WARN/Bundle(5826): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-19 20:25:03.356: WARN/Bundle(5826): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-19 20:25:03.356: WARN/Bundle(5826): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-19 20:25:03.356: WARN/Bundle(5826): at android.os.Handler.dispatchMessage(Handler.java:99)
04-19 20:25:03.356: WARN/Bundle(5826): at android.os.Looper.loop(Looper.java:123)
04-19 20:25:03.356: WARN/Bundle(5826): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-19 20:25:03.356: WARN/Bundle(5826): at java.lang.reflect.Method.invokeNative(Native Method)
04-19 20:25:03.356: WARN/Bundle(5826): at java.lang.reflect.Method.invoke(Method.java:521)
04-19 20:25:03.356: WARN/Bundle(5826): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-19 20:25:03.356: WARN/Bundle(5826): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-19 20:25:03.356: WARN/Bundle(5826): at dalvik.system.NativeStart.main(Native Method)
04-19 20:25:03.403: INFO/SurfaceFlinger(1305):
Vielen Dank für jede Anregung/jeden Leitfaden.