android - How to get String from Intent? -
i wrote code text editview, put in intent extras , set in textview on other activity.
here code sending activity
intent intent = new intent(mylayoutactivity.this, layoutforoneactivity.class); intent.putextra("captionone", string.valueof(txt_caption1.gettext())); startactivity(intent);
and here code receiving activity
intent intent1 = getintent(); bundle bundle = intent1.getextras(); if (bundle != null) { caption = bundle.getstring("captionone"); }
if try run code classcastexception looking this:
java.lang.classcastexception: android.text.spannablestring cannot cast java.lang.string
use
intent.putextra("captionone", txt_caption1.gettext().tostring);
instead of
intent.putextra("captionone", string.valueof(txt_caption1.gettext()));
and datatype of caption
should string
Comments
Post a Comment