I have an activity that I use in multiples modes, so I have to do things like this:
Intent i = new Intent(MainListActivity.this,MainActivity.class);
extras.putInt("id", c.getId());
extras.putInt("mode", AREA_MODE);
i.putExtra("extras", extras);
startActivity(i);
and in the onCreate:
Intent i = this.getIntent();
extras = i.getBundleExtra("extras");
if(extras!=null){
id = extras.getInt("id", -1);
mode = extras.getInt("mode", COUNTRY_MODE);
}
But the intent extras are always null. Am I missing something? Is there any way to do this?
EDIT: For some reason, the getIntent() method returns the previous Intent which in my case has no extra (main intent). I’m trying to figure out why.
I didn’t find the cause of this issue so i gave up on using one activity. I have create others activities extending the problematic one and it started working (with both approach). Thank you all for your help.