I'm trying to pass a serializable and an Integer or a String but on my child activity I only get the serializable
Parent Activity
Intent intent = new Intent(Class1.this, Class2.class);
Bundle bundle = new Bundle();
bundle.putInt("key", 23);
bundle.putSerializable(serializable, object);
intent.putExtras(bundle);
startActivityForResult(intent, 1);
Child Activity
Intent intent = getIntent();
int intKey;
Bundle bundle = intent.getExtras();
object = (Object) bundle.getSerializable(serializable);
intKey = bundle.getInt("key", 0);
I get the serializable object but I can't get the integer aswell
Try and put the int directly on Intent and not through bundle. Meaning :
And get it with :
Should work
But if you have a reason you wanna use the bundle you can try what Sajmon said in the comment, and
bundle.getInt("key")
i read somewhere that it's not the same, i'm not sure why.