You can use Intent extras.
In A & B:
Intent intent = new Intent(this, C.class); // Or however you do it now
intent.putExtra("caller", getClass()); // getClass must be called on the activity class here
// Do any stuff you want here to the Intent
startActivity(intent); // Or however you do it now
In onCreate
of C:
Intent intent = getIntent();
Class caller = (Class) intent.getSerializableExtra("caller");
if(caller == A.class) // A called C
And so on. Or even better, use the target classes.
In A & B:
Intent intent = new Intent(this, C.class); // Or however you do it now
intent.putExtra("target", D.class); // What should be called from C is put here
// Do any stuff to the Intent you want here
startActivity(intent); // Or however you do it now
In onCreate
of C:
Intent intent = getIntent();
Class target = (Class) intent.getSerializableExtra("target"); // Put this class somewhere
And now to create the Intent for D/E:
Intent intent = new Intent(this, target);