public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button) findViewById(R.id.button2);
Button btn2 = (Button) findViewById(R.id.button3);
Button btn3 = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,thirdActivity.class);
intent.putExtra("str", "check");
TextView txt = (TextView) findViewById(R.id.textView2);
txt.setText("Sin");
startActivity(intent);
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,thirdActivity.class);
intent.putExtra("str2", "check2");
TextView txt = (TextView) findViewById(R.id.textView2);
txt.setText("Con");
startActivity(intent);
}
});
btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent3 = new Intent(MainActivity.this,SecondActivity.class);
startActivity(intent3);
}
});
}
```IntentIntent intent = getIntent();
String message = intent.getStringExtra("str");
txt = (TextView) findViewById(R.id.textView2);
txt.setText(""+message);