예제 #1
0
 @Override
 public void run() {
   // TODO Auto-generated method stub
   mHandler.removeCallbacks(UploadRun);
   if (enable_Statistics_LOG) {
     Log.v("UICenter - StatisticsNew", LOG_TAG + "\n=UploadRun" + "\n--上传线程");
   }
   // 判断是否联网
   if (!IsHaveInternet(mContext)) {
     if (enable_Statistics_LOG)
       Log.v("UICenter - StatisticsNew", LOG_TAG + "\n=UploadRun" + "\n--没有线程");
     exitThread();
     if (enable_Statistics_LOG)
       Log.v(
           "UICenter - StatisticsNew",
           LOG_TAG
               + "\n=UploadRun"
               + "\n--没有网退出线程"
               + "---------------------exitThread--------------------");
     return;
   } else {
     String params = getLogInformation();
     if (params != null) {
       CustomerHttpClient client = new CustomerHttpClient(mContext);
       String[] res = client.post(LOG_URL_TEST, params);
       if (res != null) {
         String content = res[0];
         JSONObject json = null;
         try {
           json = new JSONObject(content);
           int retCode = json.getInt("retcode");
           if (retCode == 0) {
             delAllData();
             clearErrTimeAndCount();
             recordSuccessTime();
             if (enable_Statistics_LOG)
               Log.v(
                   "UICenter - StatisticsNew",
                   LOG_TAG
                       + "\n=UploadRun"
                       + "\n--上传成功 =============ok===================="
                       + "\n--params    = "
                       + params);
           } else {
             isUseLog = false;
             int errcount = getErrTimes();
             recordErrCount(++errcount);
             recordErrTime();
             if (enable_Statistics_LOG)
               Log.v(
                   "UICenter - StatisticsNew",
                   LOG_TAG
                       + "\n=UploadRun"
                       + "\n--上传失败=============not ok===================="
                       + "\n--params    = "
                       + params
                       + "\n--retCode    ="
                       + retCode);
           }
         } catch (JSONException e) {
           isUseLog = false;
           int errcount = getErrTimes();
           recordErrCount(++errcount);
           recordErrTime();
           if (enable_Statistics_LOG)
             Log.v(
                 "UICenter - StatisticsNew",
                 LOG_TAG
                     + "\n=UploadRun"
                     + "\n--上传失败=============not ok===================="
                     + "\n--params    = "
                     + params);
           e.printStackTrace();
         }
       } else {
         isUseLog = false;
         int errcount = getErrTimes();
         recordErrCount(++errcount);
         recordErrTime();
         if (enable_Statistics_LOG)
           Log.v(
               "UICenter - StatisticsNew",
               LOG_TAG
                   + "\n=UploadRun"
                   + "\n--上传失败=============not ok===================="
                   + "\n--params    = "
                   + params
                   + "\n--res      ="
                   + res);
       }
     }
     if (enable_Statistics_LOG)
       Log.v("UICenter - StatisticsNew", LOG_TAG + "\n=UploadRun" + "\n--关闭上传线程");
     exitThread();
   }
 }