Can't pass and retrieve CharSequence to another activity using intent.getExtras() method.
Posted
by vt
on Stack Overflow
See other posts from Stack Overflow
or by vt
Published on 2010-06-16T15:07:20Z
Indexed on
2010/06/16
15:12 UTC
Read the original article
Hit count: 142
Activity 1:
Intent i = new Intent(this, Activity2.class);
CharSequence btText = btButton.getText();
i.putExtra(BUTTON_TEXT, btText);
startActivityForResult(i, ACTIVITY_SETTINGS);
Activity 2:
in onCreate:
Bundle extras = getIntent().getExtras();
if (extras != null) {
mButtonText = extras.getCharSequence(Activity1.BUTTON_TEXT);
}
The resulting CharSequence is not what was passed, it's something like "(id=830066506776)" instead.
This works:
CharSequence test2 = getIntent().getCharSequenceExtra(Activity1.BUTTON_TEXT);
What is wrong with getExtras approach? This is what they used in Notepadv3 example. This is for Android 2.1. Thank you.
© Stack Overflow or respective owner