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

Popular posts from this blog

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -