Codenameone 连接请求问题
我在postResponse中调用了“newnewform(res).show()”,但尽管连接成功,但没有看到特定的表单。我发现如果我注释掉“cr.setDisposeOnCompletion(d)”,那么它就可以正常工作。 但是,如果发生任何异常,无限的进步就会无限地运行,以此类推。这是虫子吗?它发生在我更新到新的cn1库更新之后。如果要查看项目,请单击此处: 连接检查类Codenameone 连接请求问题,codenameone,Codenameone,我在postResponse中调用了“newnewform(res).show()”,但尽管连接成功,但没有看到特定的表单。我发现如果我注释掉“cr.setDisposeOnCompletion(d)”,那么它就可以正常工作。 但是,如果发生任何异常,无限的进步就会无限地运行,以此类推。这是虫子吗?它发生在我更新到新的cn1库更新之后。如果要查看项目,请单击此处: 连接检查类 public class ConnectionCheck { Resources res; Dialog d; p
public class ConnectionCheck {
Resources res;
Dialog d;
public ConnectionCheck(Resources res) {
this.res = res;
}
public void connectionCheckMethod() {
ConnectionRequest cr = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
JSONParser jsonp = new JSONParser();
Map<String, Object> parser = jsonp.parseJSON(new InputStreamReader(input));
System.out.println("bibek " + parser);
}
@Override
protected void postResponse() {
new NewForm(res).show();
// d.dispose();
}
@Override
protected void handleErrorResponseCode(int code, String message) {
System.out.println("login ErrorResponseCode " + code + "msg: " + message);
// d.dispose();
}
@Override
protected void handleException(Exception err) {
System.out.println("login Exception " + err);
// d.dispose();
}
@Override
protected void handleIOException(IOException err) {
System.out.println("login IOException " + err);
// d.dispose();
}
@Override
protected void handleRuntimeException(RuntimeException err) {
System.out.println("login RuntimeException " + err);
// d.dispose();
}
};
cr.setPost(true);
cr.setUrl("http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo");
cr.setTimeout(30000);
cr.addRequestHeader("Accept", "application/json");
InfiniteProgress ip = new InfiniteProgress();
d = ip.showInifiniteBlocking();
cr.setDisposeOnCompletion(d); //if this line is commented, the newForm is shown
NetworkManager.getInstance().addToQueueAndWait(cr);
}
}
在调用新窗体的显示之前,需要先处理该对话框。连接完成时Dispose on completion(完成时处置)将在连接完成时处置对话框,这有时是不可预测的
当一个对话框被释放时,它会返回到以前的形式,即显示对话框之前的形式。我在postResponse方法中调用了新形式。PostResponse()应该在connectionRequest成功后调用(即在PostResponse中的新表单之前调用完成时的dispose),不是吗?上面的代码以前是用来工作的。我现在应该做什么改变?是否必须在post响应方法和每个异常处理方法中手动处理对话框?
public class ConnectionCheck {
Resources res;
Dialog d;
public ConnectionCheck(Resources res) {
this.res = res;
}
public void connectionCheckMethod() {
ConnectionRequest cr = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
JSONParser jsonp = new JSONParser();
Map<String, Object> parser = jsonp.parseJSON(new InputStreamReader(input));
System.out.println("bibek " + parser);
}
@Override
protected void postResponse() {
new NewForm(res).show();
// d.dispose();
}
@Override
protected void handleErrorResponseCode(int code, String message) {
System.out.println("login ErrorResponseCode " + code + "msg: " + message);
// d.dispose();
}
@Override
protected void handleException(Exception err) {
System.out.println("login Exception " + err);
// d.dispose();
}
@Override
protected void handleIOException(IOException err) {
System.out.println("login IOException " + err);
// d.dispose();
}
@Override
protected void handleRuntimeException(RuntimeException err) {
System.out.println("login RuntimeException " + err);
// d.dispose();
}
};
cr.setPost(true);
cr.setUrl("http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo");
cr.setTimeout(30000);
cr.addRequestHeader("Accept", "application/json");
InfiniteProgress ip = new InfiniteProgress();
d = ip.showInifiniteBlocking();
cr.setDisposeOnCompletion(d); //if this line is commented, the newForm is shown
NetworkManager.getInstance().addToQueueAndWait(cr);
}
}
public class NewForm extends Form{
public NewForm(Resources res){
setTitle("new Form");
add(new Label("new Form"));
}
}