Dharmendra Dharmendra - 5 months ago 23
Android Question

How to find last activity from which current activity is opened in android?

I have one activity which can be open from more 4 or 5 different activity so i can find from which activity my current activity is called...

If any idea please help me..


You might want to add extras to the intent you use to start the activity to indicate where the intent is coming from or what the request is.

For example:

Intent intent = new Intent(this, OtherActivity.class);
intent.putExtra("caller", "MainActivity");

and then your OtherActivity could detect the "caller" in its onCreate:

String caller     = getIntent().getStringExtra("caller");
Class callerClass = Class.forName(caller);