我是 Codenameone 的新手,我在 Codenameone 的 ConnectionRequest API 中遇到了奇怪的问题,同时从安装了 anroid 10 的谷歌像素设备中的 https 站点获取响应。从 https 站点获取工作正常。
然而,在模拟器中它很好,并且在其他安卓版本低于 10 的设备上也很好。
这可能是什么解决方案,或者我在做什么?
这是我在设备中遇到的代码和错误
第一次尝试:
TextArea resultTextArea = new TextArea();
Button download = new Button("RUN");
download.addActionListener((e) -> {
ConnectionRequest cr = new ConnectionRequest(url, false);
SliderBridge.bindProgress(cr, progress);
NetworkManager.getInstance().addToQueueAndWait(cr);
if (cr.getResponseCode() == 200) {
String resultString = "";
try {
byte[] initialArray = cr.getResponseData();
resultString = new String(initialArray);
resultTextArea.setText(resultString);
} catch (Exception eee) {
resultString = "Error => " + resultString + eee.getMessage();
}
System.out.println(resultString);
}
});
第二次尝试:其中 url = http://192.168.2.100:8084/semms-webservice/rest/device/test/users
public void testURLConnectionResponse(String url) {
ConnectionRequest request = new ConnectionRequest();
request.setContentType("application/json");
request.setUrl(url);
request.setHttpMethod("GET");
TextArea resultTextArea = new TextArea();
String result = "";
result = "RESPONSE CODE :- " + request.getResponseCode() + " --- ";
Response<String> resultx = Rest.put(url).getAsString();
result += resultx.getResponseData();
resultTextArea.setText(result);
Form hi = new Form("Test Connection Response", new BoxLayout(BoxLayout.Y_AXIS));
Button mainFormButton = new Button("Back To Main Form");
mainFormButton.addActionListener((e) -> mainForm());
mainFormButton.setRippleEffect(true);
hi.add(mainFormButton);
hi.show();
// request will be handled asynchronously
NetworkManager.getInstance().addToQueue(request);
}
enter code here