diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/BooleanFormField.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/BooleanFormField.java index 85e351649..6208e4979 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/BooleanFormField.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/BooleanFormField.java @@ -35,7 +35,17 @@ public class BooleanFormField extends SingleValueFormField { return value.toString(); } - public Boolean getValueAsBoolean() { + /** + * Get the value of the booelan field. Note that, if no explicit boolean value is provided, in the form of "true", + * "false", "0", or "1", then the default value of a boolean field is false, according to + * XEP-0004 ยง 3.3. + * + * @return the boolean value of this form field. + */ + public boolean getValueAsBoolean() { + if (value == null) { + return false; + } return value; }