• 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
  • 相关阅读:
    redis配置文件参数说明及命令操作
    在Window 下安装Redis数据库
    eclipse怎样在线安装hibernate tools插件并使用
    eclipse如何优化构建的速度(Building)
    java实现敏感词过滤(DFA算法)
    eclipse编码格式设置
    Jquery Ajax简单封装(集中错误、请求loading处理)
    Vue简单封装axios—解决post请求后端接收不到参数问题
    vue项目实现记住密码功能
    vue路由的两种模式配置以及history模式下面后端如何配置
  • 原文地址:https://www.cnblogs.com/U-tansuo/p/android_http.html
Copyright © 2020-2023  润新知