Android Studio See What Activity You Came From

[Solved] Android Studio See What Activity You Came From | Kotlin - Code Explorer | yomemimo.com
Question : android studio see what activity you came from

Answered by : andreas-karabetian-btuo2nvzlvfc

// Activity A and Activity B both send to Activity C
// In order to decide which Activity you came from use the following code:
// In Activity A:
Intent intent = new Intent(this, C.class);
intent.putExtra("camefrom", "A");
startActivity(intent);
// In Activity B:
Intent intent = new Intent(this, C.class);
intent.putExtra("camefrom", "B");
startActivity(intent);
// In Activity C:
Intent intent = getIntent();
String cameFrom= intent.getStringExtra("camefrom");
if(cameFrom.equals("A");
// It is from A
else
// It is from B

Source : https://stackoverflow.com/questions/21953839/how-to-decide-which-activity-we-came-from | Last Update : Wed, 09 Mar 22

Answers related to android studio see what activity you came from

Code Explorer Popular Question For Kotlin