When I try to run the code below, my program has stops. I want this code to get the value from edittext
but it´s not working as I expected it. What am I doing wrong
The problem seems that when Activity is bringed to front there is no value in EditText
. Integer parser don't know how to parse empty String, so Exception is thrown.
You need to check for existing of text in that EditText
before parsing
final int f = -1; // or other invalid value
if (from.getText().toString().length() > 0)
f = Integer.parseInt(from.getText().toString());
Similarly for other EditText