All over the net I see examples like edittext.getText().toString()
. I do not see any null check. In docs I do not see any statement that would say that this wil
With Android P SDK it is annotated as nullable in the AppCompatEditText
class so it can return null.
And from the docs:
Return the text that the view is displaying. If an editable text has not been set yet, this will return null.
@Override
@Nullable
public Editable getText() {
if (Build.VERSION.SDK_INT >= 28) {
return super.getText();
}
// A bug pre-P makes getText() crash if called before the first setText due to a cast, so
// retrieve the editable text.
return super.getEditableText();
}