安卓真机上使用getXMLHttpRequest访问接口数据

getXMLHttpRequest安卓真机上不能访问服务器接口 在访问时 连接的readyState 一直处于1的状态.但是在 浏览器测试时 是能够正常访问的。请问这个有办法解决嘛! 我的代码如下
this.httpPost=function (url, params, callback) {
var xhr = cc.loader.getXMLHttpRequest();
var sendstr=JSON.stringify(params);
xhr.onreadystatechange = function () {
// cc.log(‘xhr.readyState=’+xhr.readyState+’ xhr.status=’+xhr.status);
if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 300)) {
var respone = xhr.responseText;
callback(JSON.parse(respone));
}else{
// callback(-1);
cc.find(“Canvas/username/editbox”).getComponent(cc.EditBox).string=xhr.readyState;
}
};

    xhr.open("POST", rootPath+url, true);
    if (cc.sys.isNative) {
        xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
    }
    xhr.setRequestHeader("Content-Type","application/json");

    // note: In Internet Explorer, the timeout property may be set only after calling the open()
    // method and before calling the send() method.
    xhr.timeout = 5000;// 5 seconds for timeout

    xhr.send(sendstr);
}

不要沉

不要沉

你好,你的问题解决了吗?我访问的时候,在原生情况下,我访问一直崩溃呢。

你不是在安卓9.0上测试的吧

你好,是android 8.0上面测试的,但是在android 6.0上一样要崩溃。

兄弟 解决了吗?

如果有这样的问题,提供个测试demo和文件链接,还有测试平台。