I have Activity B and Activity C , in which Activity A can be triggered using Intent .

How to recognize in Activity A , which of them was launched?

  • four
    You can try to write something like intent.putExtra ("activity", "B") and intent.putExtra ("activity", "C"), and in activity A to do the check - Ksenia

1 answer 1

the simplest: in Activi B -

 Intent bIntent = new Intent(ActivityB.this, ActivityA.class); bIntent.putExtra("activity_type", "activityB"); startActivity(bIntent); 

In Activation C -

 Intent сIntent = new Intent(ActivityС.this, ActivityA.class); сIntent.putExtra("activity_type", "activityС"); startActivity(сIntent); 

In Activation A -

 @override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState) // other String type = getIntent().getStringExtra("activity_type") // other }