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.java:1326)
[Bundle]    at android.content.Intent.getCharSequenceArrayListExtra(Intent.java:4224)
[Bundle]    at android.content.Intent.migrateExtraStreamToClipData(Intent.java:6682)
[Bundle]    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1410)
[Bundle]    at android.app.Activity.startActivityForResult(Activity.java:3351)
[Bundle]    at android.app.Activity.startActivityForResult(Activity.java:3312)
[Bundle]    at android.app.Activity.startActivity(Activity.java:3522)
[Bundle]    at android.app.Activity.startActivity(Activity.java:3490)
[Bundle]    at at.advokat.a4mobil.viewmodel.ActLeistung.n_onClick(Native Method)
[Bundle]    at at.advokat.a4mobil.viewmodel.ActLeistung.onClick(ActLeistung.java:131)
[Bundle]    at android.view.View.performClick(View.java:4103)
[Bundle]    at android.view.View$PerformClick.run(View.java:17117)
[Bundle]    at android.os.Handler.handleCallback(Handler.java:615)
[Bundle]    at android.os.Handler.dispatchMessage(Handler.java:92)
[Bundle]    at android.os.Looper.loop(Looper.java:137)
[Bundle]    at android.app.ActivityThread.main(ActivityThread.java:4744)
[Bundle]    at java.lang.reflect.Method.invokeNative(Native Method)
[Bundle]    at java.lang.reflect.Method.invoke(Method.java:511)
[Bundle]    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
[Bundle]    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[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.