安卓原生平台网络访问失败

类似的代码如下:

    var xhr = this._createXMLHttpRequest();
    xhr.responseType = "arraybuffer";

    var self = this;
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
            //cc.log("request return.");

            //处理完成
        }
        else if( xhr.status >= 400 ){
            //发生错误了
            cc.warn("net access status 400 error:" + xhr.status);
            cb(-1,"");
        }
        else if(xhr.readyState >= 4 ){
            cc.log("unknown net request status:" + xhr.status);
        }
    };

    xhr.onerror = function(e , e2){
        cc.warn("net access error:" + e + ",e2:" + e2) + ", xhr status=" + xhr.status;
        //cb(-3,"网络访问错误:" + e);
        cb(-3,"");
    };
    
    xhr.open("POST", url, true);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    xhr.send(datas.toBufferArray());

function _createXMLHttpRequest(){
var xmlrequest = null;
if( window.XMLHttpRequest){
xmlrequest = new window.XMLHttpRequest();
}
else{
// IE浏览器
try{
xmlrequest = new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e){
try{
xmlrequest = new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch (e){
}
}
}

return xmlrequest;

}

最后显示net access error:,服务端跟踪的确正常返回了。(注,网页 版本无问题,就是android机器上不行),有没有高手看出哪里出故障了?

你手机的安卓版本?你编译的安卓版本?

是的啊!

如果你手机的安卓版本高于9.0需要配置权限的