Converting String to Double in Android
I would do it this way:
try { txtProt = (EditText) findViewById(R.id.Protein); // Same p = txtProt.getText().toString(); // Same protein = Double.parseDouble(p); // Make use of autoboxing. It's also easier to read.} catch (NumberFormatException e) { // p did not contain a valid double}
EDIT: "the program force closes immediately without leaving any info in the logcat"
I don't know bout not leaving information in the logcat output, but a force-close generally means there's an uncaught exception - like a NumberFormatException.
You seem to assign Double object into native double value field. Does that really compile?
Double.valueOf() creates a Double object so .doubleValue() should not be necessary.
If you want native double field, you need to define the field as double and then use .doubleValue()