Java.lang.classcastexception: Android.text.spannablestringbuilder Cannot Be Cast To Java.util.arraylist
I'm using the phonegap Android plugin: EmailComposerwithAttachments https://github.com/phonegap/phonegap-plugins/tree/master/Android/EmailComposerWithAttachments and it occurs the
Solution 1:
It's down this this bug in Android 4.x
You can work around the problem for plain text emails by replacing this line in EmailComposer.java:
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
with
ArrayList<String> extra_text = newArrayList<String>();
extra_text.add(body);
emailIntent.putStringArrayListExtra(android.content.Intent.EXTRA_TEXT, extra_text);
But this won't work for HTML emails because Spanned (returned by Html.fromHtml) is not a subclass of Charsequence. When I tried casting the result of Html.fromHtml() to a string, the tags appeared as part of the text :-(
Also when I tried this, the body of plain text emails to appeared when using the Gmail app but it didn't appear in stock Email app - body was always blank.
Solution 2:
Just try a different approach:
IntentemailIntent=newIntent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, body);
//emailIntent.putExtra(Intent.EXTRA_HTML_TEXT, body); //If you are using HTML in your body text
startActivity(Intent.createChooser(emailIntent, "Chooser Title"));
taken from here: Send Email Intent
Post a Comment for "Java.lang.classcastexception: Android.text.spannablestringbuilder Cannot Be Cast To Java.util.arraylist"