zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    [HTML] IE=edge,chrome=1的META标签详解
    [FFmpeg] ffmpeg 常用命令
    rsyncd 配置使用
    httpd配置
    ftp利用脚本添加本地用户
    zabbix监控概念
    搭建本地yum源并定时同步
    linux添加lvm磁盘大小,命令行创建swap
    500 OOPS: vsftpd: refusing to run with writable root inside chroot()
    利用saltstack批量安装clamav杀毒软件
  • 原文地址:https://www.cnblogs.com/U-tansuo/p/android_http.html
Copyright © 2011-2022 走看看