quick2.26 android下http崩溃

quick2.26 http android下崩溃解决方案

1、先去quick官网合并代码(QuickHTTPInterface.java,CCHTTPRequestAndroid.cpp)

2、屏蔽调request->start();代码

#if (CC_CURL_ENABLED > 0 || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)

CCHTTPRequest* CCNetwork::createHTTPRequest(CCHTTPRequestDelegate* delegate,
                                            const char* url,
                                            int method)
{
    CCHTTPRequest* request = CCHTTPRequest::createWithUrl(delegate, url, method);
   // request->start();
    return request;
}

#if CC_LUA_ENGINE_ENABLED > 0
CCHTTPRequest* CCNetwork::createHTTPRequestLua(LUA_FUNCTION listener,
                                               const char* url,
                                               int method)
{
    CCHTTPRequest* request = CCHTTPRequest::createWithUrlLua(listener, url, method);
   // request->start();
    return request;
}
#endif

#endif // CC_CURL_ENABLED

3 调用方式:

get:

local function postCallBack(event)
  local request = event.request
  local state = request:getState()
  if state == 3 then
    local parseStr = request:getResponseString()

  end

end



local url = "url" local targetPlatform = CCApplication:sharedApplication():getTargetPlatform() local httptest = nil if kTargetAndroid == targetPlatform then httptest = CCNetwork:createHTTPRequest(postCallBack,url,kCCHTTPRequestMethodGET) else httptest = CCHTTPRequest:createWithUrl(postCallBack,url,kCCHTTPRequestMethodGET) end httptest:start()

post:

local function postCallBack(event)
    local request = event.request
    local state = request:getState()
   if  state == 3  then
        local parseStr =  request:getResponseString()
        print("parseStr****"..parseStr)
    end
end

function PlatformLocal:doLoginLocal()
     local url = "url"
   local targetPlatform = CCApplication:sharedApplication():getTargetPlatform()
     local httptest = nil
    if kTargetAndroid == targetPlatform then
         httptest = CCNetwork:createHTTPRequest(postCallBack,url,kCCHTTPRequestMethodPOST)        
    else
         httptest = CCHTTPRequest:createWithUrl(postCallBack,url,kCCHTTPRequestMethodPOST)
    end

    httptest:addPOSTValue('username', "1212") -- 添加post中的传递参数 key 和value
    httptest:addPOSTValue('password', "asasas") -- 添加post中的传递参数 key 和value
    httptest:addPOSTValue('timestamp','1461117993') -- 添加post中的传递参数 key 和value
    httptest:start()     
end
原文地址:https://www.cnblogs.com/U-tansuo/p/android_http.html