Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #android #studio #activity
ADD COMMENT
Topic
Name
9+5 =