I have two buttons.
Button1
go to A then C
Button2
go to A then B and finally C.
There are values pass between these activities. The problem I faced now is how do I check whether they are data pass from B to C or it is from A to C only so I can set different condition to them.
Activity A
btnNext.setOnClickListener(new View.OnClickListener() { //if button1 is clicked
@Override
public void onClick(View v) {
Intent intent=new Intent(getApplicationContext(),C.class); //pass spinner value and date to next class
Name = name.getSelectedItem().toString();
Weather = weather.getSelectedItem().toString();
Status=status.getSelectedItem().toString();
intent.putExtra("Name",Name);
intent.putExtra("Weather",Weather);
intent.putExtra("Status",Status);
intent.putExtra("date2",date2);
startActivity(intent);
}
});
btnForce.setOnClickListener(new View.OnClickListener() { // if button2 clicked
@Override
public void onClick(View v) {
Intent intent=new Intent(getApplicationContext(),B.class);
Name = name.getSelectedItem().toString();
Weather = weather.getSelectedItem().toString();
Status=status.getSelectedItem().toString();
intent.putExtra("Name",Name);
intent.putExtra("Weather",Weather);
intent.putExtra("Status",Status);
intent.putExtra("date2",date2);
startActivity(intent);
}
});
Activity B
goDetails.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { // if next button is clicked
Intent intent = new Intent(getApplicationContext(), C.class);
sub = SubContractors.getText().toString();
noP = NoPerson.getText().toString();
noH=NoHours.getText().toString();
intent.putExtra("sub",sub);
intent.putExtra("noP",noP);
intent.putExtra("noH",noH);
intent.putExtra("name",name);
intent.putExtra("weather",weather);
intent.putExtra("status",status);
intent.putExtra("date",date);
startActivity(intent);
}
});
}
Activity c
name = getIntent().getExtras().getString("Name"); // receive name from Information
weather = getIntent().getExtras().getString("Weather"); //receive weather
date = getIntent().getExtras().getString("date2"); //receive date
status = getIntent().getExtras().getString("Status"); // receive status
If has data passes from B, what should I write ?