燃油TimeOut连接

时间:2017-12-05 13:11:30

标签: android kotlin

嘿伙计们,我正在处理我正在处理的应用程序的问题,特别是在Galaxy 6上

应用程序需要做的是在收到或为其创建的数据后发送服务器请求我正在使用BroadcastReceiver()来接收使用

的呼叫

intent.action ==“android.intent.action.NEW_OUTGOING_CALL”

声明,如果它不正确,这意味着呼叫已经收到,无论如何我的问题是,无论何时收到呼叫或启动呼叫,我的燃料后请求大部分时间超时错误异常!!

我尝试更换一个库(amitshekhariitbhu / Fast-Android-Networking),但异常返回,问题只是在该设备上导致其他设备运行起来很好

我的代码   覆盖funInIncomingCallReceived(ctx:Context?,number:String?,start:Date?)     {         MyApplicationClass.instance.printLog(“State A0”);

    MyApplicationClass.instance.upDateUserStatus(ctx,"RING",number,start?.time.toString(),"fasle",object : MyApplicationClass.PushReplacer
    {
        override fun replacedPush(jsonObject: JSONObject)
        {
            MyApplicationClass.instance.printLog("State A3 ");
            if(ctx != null && jsonObject != null) MyApplicationClass.instance.openNotif(ctx!!,jsonObject);
        }

    },true);

    Log.e("Phone", "onIncomingCajllReceived");
    Log.e("call", "A6");
}



    doAsync {

        ServerRequestName.change_user_status.httpPost()
                .header("Content-Type" to "application/json")
                .header("JWToken" to getJWToken(context))
                .header("encrypt" to Constants.instance.ENCRYPT)
                .body(bodyParameters(status,i_am_talking_with,timeStamp,report).toString())
                .timeout(10000)
                .timeoutRead(60000)
                .responseString{request, response, result ->
                    when(result)
                    {
                        is Result.Success->
                        {
                            val data : JSONObject = JSONObject(result.get());

                            if(data.has("error"))
                            {
                                uiThread {

                                    MyApplicationClass.instance.printLog("State A2 Data Sended Call Failed status1:$status talking with: $i_am_talking_with")
                                    //recieved data but had error in it//

                                    if(reConnectOnFail)
                                    {
                                        MyApplicationClass.instance.printLog("State A2 Data Sended Call Success status1:$status talking with: $i_am_talking_with")
                                        upDateUserStatus(context,status,i_am_talking_with,timeStamp,report,pushreplacer,false)
                                    }

                                }
                            }
                            else
                            {
                                uiThread {

                                    MyApplicationClass.instance.printLog("State A1 Data Sended Call Success status2:$status talking with: $i_am_talking_with")

                                    if(data.has("push") && data.getJSONObject("push").length() != 0)
                                    {
                                        pushreplacer.replacedPush(data.getJSONObject("push"));
                                    }

                                }
                                //recieved data successfully//
                            }

                        }

                        is Result.Failure->
                        {

                            val data : JSONObject = JSONObject(result.get());

                            MyApplicationClass.instance.printLog("State A2 Data Sended Call Failed status:$status talking with: $i_am_talking_with");

                            uiThread {

                                if(reConnectOnFail)
                                {
                                    upDateUserStatus(context,status,i_am_talking_with,timeStamp,report,pushreplacer,false)
                                }
                            }

                            //recieved error//
                        }
                    }
                }

    }
}

0 个答案:

没有答案