I have 3 activity: Activity1, Activity2, Activity3. Activity1 and Activity3 can start Activity2:
startActivity (new Intent(this,Activity2));
How in Activity2 I can check which class start Activity2 ? Is there any way to take information from Intent ? Thanks…
I dont whant to put anything in Intent. I think I dont need that. When I start intent I already saying from what context I do that (new Intent(*this*,Activity2)). And this “this” I want to recognize in Activity2 !!! Is that possible ?
You can pass that information in the “extra”
Bundleof yourIntent:In
Activity1:In
Activity2:There’s also get/put extra methods for other data types like
boolean,int, etc.As for why you cannot access the
Contextyou supplied when creating theIntenton the other side:The only thing that Android does with the supplied
Context(i.e. yourthis) is to create aComponentNamefrom it. That class only keeps the package of the suppliedContextand discards anything else.So you theoretically could put your activities into different packages and then go
getIntent().getComponentName().getPackageName()on it at the receiving end — but please don’t.Intentextras is the way to go.