On testing my application in Simulator, my app runs perfectly. But on the real device i get Null for BasicEditField, so I’m not able to execute my application. Following is my code snippet.
public class Login extends MainScreen {
private UiApplication application = UiApplication.getUiApplication();
private BasicEditField _email = null;
private PasswordEditField _pwd = null;
private ButtonField login = null;
String imei = GPRSInfo.imeiToString(GPRSInfo.getIMEI(), false);
public Login(){
try {
_email = new BasicEditField("Email: ", "", 100, EditField.NO_NEWLINE);
_email.setFont(font);
add(_email);
_pwd = new PasswordEditField("Password: ", "", 100, EditField.NO_NEWLINE);
_pwd.setFont(font);
add(_pwd);
login = new ButtonField("Login", ButtonField.CONSUME_CLICK);
login.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
String e = _email.getText();
String xmlUrl = "http://********:9090/com.infra.rest/rest/todo?email='"+ e +"'&dId='"+ imei +"';deviceside=true";
String[][] urlData = XmlFunctions.getUserFromXml(xmlUrl);
}
});
login.setFont(font);
add(login);
} catch (Exception e) {
System.out.println("Failed to create user interface components");
}
}
}
On inspecting the email and imei values i get NULL and an exception saying Method “toString” with signature “()Ljava/lang/String;” is not applicable on this object
It has been a whole day but i’m not able to overcome this problem.
I suspect it has something to do with accessing non-static outer class fields from an anonymous inner class. Try:
Have a read through this wikipedia page.