This is your first activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.q_050);
Bundle value = getIntent().getExtras();
String str= value.getString("sent").toString();
if(str =="activity_two"){
Toast.makeText(getApplicationContext(), "next message", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.checkpoint), Toast.LENGTH_SHORT).show();
}
}
This is your second activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
returnButton = (Button) findViewById(R.id.returnButton);//button to return to previous activity
returnButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(SecondActivity.this,
FirstActivity.class);
intent.putExtra("sent", "activity_two"); //here 1 is a number used in first activity for if else
startActivity(intent);
}
});
}