Me da este error en particular java.lang.RuntimeException: Unable to start activity
, la aplicacion crashea al ejecutar Run MainActivity , he debuggeado el programa y me devuelve savedInstanceState como Null
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText dato1 = (EditText) findViewById(R.id.editText);
final EditText dato2 = (EditText) findViewById(R.id.editText2);
final Button boton_enviar = (Button) findViewById(R.id.boton);
final RadioButton rb1 = (RadioButton) findViewById(R.id.checkBox);
final RadioButton rb2 = (RadioButton) findViewById(R.id.checkBox2);
final RadioButton rb3 = (RadioButton) findViewById(R.id.checkBox3);
final RadioButton rb4 = (RadioButton) findViewById(R.id.checkBox4);
boton_enviar.setOnClickListener(new View.OnClickListener() {
String v1 = dato1.getText().toString();
String v2 = dato2.getText().toString();
int operador1 = Integer.parseInt(v1);
int operador2 = Integer.parseInt(v2);
final double suma = operador1 + operador2;
final double resta = operador1 - operador2;
final double multiplicacion = operador1 * operador2;
final double division = operador1 / operador2;
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,Main2Activity.class);
if (rb1.isSelected()) {
intent.putExtra("suma",suma);
} else if (rb2.isSelected()) {
intent.putExtra("resta",resta);
} else if (rb3.isSelected()) {
intent.putExtra("mult",multiplicacion);
} else if (rb4.isSelected()) {
intent.putExtra("divicion",division);
}
startActivity(intent);
}
});
}
}