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
  • 相关阅读:
    SQL行转列问题
    pgAdmin III 单表数据的导出导入
    window 服务的安装和卸载
    将Excel表格转成DataTable
    “Timeout 时间已到。在操作完成之前超时时间已过或服务器未响应”解决方法
    form-data提交
    由于本公司项目需要,现急需拥有微软MCSE证书的人才,一经录用,待遇从优!
    Head First设计模式悟道
    entityframwork
    .net 开源模板引擎jntemplate 教程:基础篇之在ASP.NET MVC中使用Jntemplate
  • 原文地址:https://www.cnblogs.com/U-tansuo/p/android_http.html
Copyright © 2011-2022 走看看