I have some class.
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent newintent = new Intent(getApplicationContext(),Main2Activity.class);
newintent.putExtra("SOME_Data", "Perfect_Data");
startActivity(newintent);
finish();
}
}
I want to retrive some data in another class.
public class Main2Activity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Intent i = this.getIntent();
Bundle s = getIntent().getExtras();
}
}
But when i launch this code,instead bundle with string "Perfect_Data" I get this error "Bundle[mParcelledData.dataSize=68]".
Can you help me?
If you want to print the content of Bundle, use this:
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
Log.d(TAG, String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}
Otherwise it just uses the default toString() of the Object class, which is what you got.