Android get previous activity

You can use the putExtra attribute of the Intent to pass the name of the Activity.

Calling Activity,

Intent intent = new Intent(this, Next.class);
intent.putExtra("activity","first");
startActivity(intent);

Next Activity,

Intent intent = getIntent();
String activity = intent.getStringExtra("activity");

Now in the string activity you will get the name from which Activity it has came.

Leave a Comment