Using keys for passing values between activities
The keys of the 2 extras are "com.example.testapp.num1"
and "com.example.testapp.num2"
, so you must use these to retrieve them and not "num1"
and "num2"
:
if (getIntent().hasExtra("com.example.testapp.num1") && getIntent().hasExtra("com.example.testapp.num2")){
int num1=getIntent().getExtras().getInt("com.example.testapp.num1");
int num2=getIntent().getExtras().getInt("com.example.testapp.num2");
TextView bigger=findViewById(R.id.biggerNView);
bigger.setText(String.valueOf(Math.max(num1,num2)));
}