Log is saying activity cant be paused, and a number format exception, I'm trying to save state of two edit texts that hold numbers,but both can be empty or one can be empty
In my activity there are two edit texts the user can either enter numbers manually and move to the next step or open a calculator to add up some numbers, and set the total to one of the edit texts, i want to save the state so if he needs to fill both edit text using the calculator, the first number he set will still be there when they come back with the second number.
I don't know to deal with this, here is the last bit of code i tried.
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
double length =Double.parseDouble(edtNumber1.getText().toString());
double height = Double.parseDouble(edtNumber2.getText().toString());
outState.putDouble("LENGTH", length);
outState.putDouble("HEIGHT", height);
}
And in onCreate
if (savedInstanceState != null) {
double hght = savedInstanceState.getDouble("LENGTH");
double lnth = savedInstanceState.getDouble("LENGTH");
if (savedInstanceState.containsKey("LENGTH")); {
edtNumber1.setText(Double.toString(lnth));
}
if(savedInstanceState.containsKey("HEIGHT")); {
edtNumber2.setText(Double.toString(hght));
}
}