我已經有一年的時間&需要更新。它是用國家機器書寫的。現在我添加了一些東西,但connectionRequest在iOS中似乎不起作用(它是爲iOS調試而構建的)。我在android中構建它,它工作得很好。ConnectionRequest在iOS中無法正常工作
public void connectionForLogin(String username, String password) {
ConnectionRequest cr = new ConnectionRequest() {
@Override
protected void readResponse(InputStream input) throws IOException {
JSONParser jSONParser = new JSONParser();
Map<String, Object> parsedData = jSONParser.parseJSON(new InputStreamReader(input));
ArrayList<Map<String, Object>> response = (ArrayList<Map<String, Object>>) parsedData.get("root");
if (response != null) {
for (Map<String, Object> element : response) {
success = (String) element.get("login");
msg = (String) element.get("msg");
ArrayList<Map<String, Object>> userInfoArray = (ArrayList) element.get("user_info");
Storage.getInstance().writeObject("userInfo", userInfoArray);
}
}
}
@Override
protected void postResponse() {
super.postResponse();
}
@Override
protected void handleErrorResponseCode(int code, String message) {
}
@Override
protected void handleException(Exception err) {
}
@Override
protected void handleIOException(IOException err) {
}
@Override
protected void handleRuntimeException(RuntimeException err) {
}
};
cr.setPost(true);
cr.setDuplicateSupported(true);
cr.setTimeout(30000);
AllUrl au = new AllUrl();
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
cr.setDisposeOnCompletion(d);
cr.setUrl(http://zzz.com/api/logins/match? + "username=" + username + "&password=" + password);
NetworkManager.getInstance().addToQueueAndWait(cr);
}
這是由於網址? API在http中,我認爲iOS需要https。但如果是這樣,爲什麼以前的版本工作正常? – beck