Answers for "android studio see what activity you came from"

0

android studio see what activity you came from

// 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
Posted by: Guest on March-02-2022

Code answers related to "android studio see what activity you came from"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language