Problem setting email text with multiple attachments

I'm having a problem opening an email with multiple attachments. When I set the emails text the normal way:

Intent mailIntent = new Intent(Intent.ActionSendMultiple);
mailIntent.PutExtra(Intent.ExtraText, "email text");

the email shows up with the text set (in the emulator and on my old Sony Xperia P phone), but I get the following exception:

[Bundle] Key android.intent.extra.TEXT expected ArrayList<CharSequence> but value was a java.lang.String.  The default value <null> was returned.
[Bundle] Attempt to cast generated internal exception:
[Bundle] java.lang.ClassCastException: java.lang.String cannot be cast to java.util.ArrayList
[Bundle]    at android.os.Bundle.getCharSequenceArrayList(
[Bundle]    at android.content.Intent.getCharSequenceArrayListExtra(
[Bundle]    at android.content.Intent.migrateExtraStreamToClipData(
[Bundle]    at
[Bundle]    at
[Bundle]    at
[Bundle]    at
[Bundle]    at
[Bundle]    at at.advokat.a4mobil.viewmodel.ActLeistung.n_onClick(Native Method)
[Bundle]    at at.advokat.a4mobil.viewmodel.ActLeistung.onClick(
[Bundle]    at android.view.View.performClick(
[Bundle]    at android.view.View$
[Bundle]    at android.os.Handler.handleCallback(
[Bundle]    at android.os.Handler.dispatchMessage(
[Bundle]    at android.os.Looper.loop(
[Bundle]    at
[Bundle]    at java.lang.reflect.Method.invokeNative(Native Method)
[Bundle]    at java.lang.reflect.Method.invoke(
[Bundle]    at$
[Bundle]    at
[Bundle]    at dalvik.system.NativeStart.main(Native Method)

This seems to be an Android bug, I found this solution: Issue 38303: ClassCastException warning in log when opening e-mail app with a body and multiple file attachments.
In Xamarin the code now looks like this:

JavaList<string> txt = new JavaList<string>();
txt.Add("email text");
mailIntent.PutStringArrayListExtra(Intent.ExtraText, txt);

So now the exception is gone... but on my devices the email text IS NOT GETTING SET any more.

Any ideas... anybody? How can i get the text and NO exception? Thanks in advance.

Sign In or Register to comment.