2017-03-24 12 views
0

휴대 전화가 잠자기 모드로 전환 된 다음 앱으로 돌아갈 때 발리 요청이 너무 느려지는 며칠 동안 알 수없는 문제에 직면하고 있습니다. , 나는 너무 많은 Retrypolicies 발리에 의해 주어진 노력했지만, 그들 중 누구도 올바르게 작동하지 않습니다. 아래 예제 코드는 데이터를 얻기 위해 발리를 요청합니다.전화가 잠자기 상태가되어 응용 프로그램으로 다시 돌아올 때 발리 요청이 너무 느려짐

JsonObjectRequest movieReq = new JsonObjectRequest(
        "MyURL" + session.getBusinessUserRegisterID(), 
        null, 

        new Response.Listener<JSONObject>() { 
         @Override 
         public void onResponse(JSONObject response) { 

          try { 

           String Connectionscount = response.getString("Connections"); 
           String Expiredcountval = response.getString("Expired"); 
           String Livecountval = response.getString("Live"); 
           String NewCustomerscount = response.getString("NewCustomers"); 
           String NewNotificationscount = response.getString("NewNotifications"); 
           String SmsBalancecount = response.getString("SmsBalance"); 
           String TotalCustomercount = response.getString("TotalCustomer"); 


           Newnotificationscount.setText(NewNotificationscount); 
           Livecount.setText(Livecountval); 
           Expiredcount.setText(Expiredcountval); 
           Totalcustcount.setText(TotalCustomercount); 
           Newcustcount.setText(NewCustomerscount); 
           Myconnectionscount.setText(Connectionscount); 
           Smscount.setText(SmsBalancecount); 
           ringProgressDialog.dismiss(); 
           mSwipeRefreshLayout.setRefreshing(false); 
          } catch (JSONException e) { 

           e.printStackTrace(); 

          } 

         } 
        }, new Response.ErrorListener() { 
       @Override 
       public void onErrorResponse(VolleyError error) { 


       } 

      }); 
      movieReq.setRetryPolicy(
        new DefaultRetryPolicy(
          10000,0,1f 
        ) 
      ); 

      AppController.getInstance().addToRequestQueue(movieReq); 
DefaultRetryPolicy보다 0 번째 매개 변수를 배치

첫 번째 경우, 그것은 발리 있지 않으면 0 그래서들 수 오류로 두번째 파라미터를 배치하는 응답을

movieReq.setRetryPolicy(
        new DefaultRetryPolicy(
          10000,1,1f 
        ) 
      ); 

번째 경우를 제공하는 데 시간이 너무 오래 걸리는 10 초 동안 응답합니다 (재시도 경고 표시).

movieReq.setRetryPolicy(
        new DefaultRetryPolicy(
          10000,0,1f 
        ) 
      ); 
+0

는 응답 @의 BasuSingh.what에 대한 우선 순위 = HIGH –

+0

감사하고 내가 그 곳을 줄 수있는 우선 순위를 부여하려고? –

+0

답변으로 코드를 작성했습니다. –

답변

0

시도 설정 우선 순위 높은 같이

@Override 
public Priority getPriority() { 
     return Priority.HIGH; 
}