Android Volley double post when have slow request

后端 未结 18 2745
生来不讨喜
生来不讨喜 2020-11-28 04:06

I have a problem with Volley POST request on slow network. Everytime I see BasicNetwork.logSlowRequests in my LogCat, my POST request is executed twice or more

18条回答
  •  盖世英雄少女心
    2020-11-28 04:34

    Volley request policy only one time request to avoid duplicate post

    I tried this solution, but does not working

    //...........solution 01
    jsonObjectRequest.retryPolicy = DefaultRetryPolicy(
    120000, 
    0,
    DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)
    
    
    or
    
    //...........solution 02
    jsonObjectRequest.retryPolicy = DefaultRetryPolicy(
    0, 
    -1,
    DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)
    
    
    MySingleton.getInstance(this).addToRequestQueue(jsonObjectRequest)
    

    Full Source Code: https://androidkeynotes.blogspot.com/2020/02/volley.html

提交回复
热议问题