In the intent that start the Second
, put some Bundle
data to mark whether this intent is from First
or Third
. Detail is here.
If I do,
// Constants.java
public static class Constants {
public static String BUNDLE_KEY_FROM = "_BUNDLE_KEY_FROM";
}
And in the First
and Third
,
Intent intent = new Intent(this, Second.class);
intent.putExtra(Constants.BUNDLE_KEY_FROM, "First"); // or "Third"
startActivity(intent);
And then in the Second.onCreate()
,
Bundle extras = getIntent().getExtras();
if (extras != null) {
// get data via the key
String val = extras.getString(Constants.BUNDLE_KEY_FROM);
if (val.equals("First") ) {
funcFirst();
}else if(val.equals("Third") ){
funcThird();
}
}