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");
startActivity(intent);
and then your OtherActivity could detect the “caller” in its onCreate:
String caller = getIntent().getStringExtra("caller");
Class callerClass = Class.forName(caller);