Text after "
I want to request the use of the Volley Library in a separate thread.
This means that there is a connection that is in a trid and there is a data process in the uThade. I want to do this because I have lots of connections, so to process so many data and today I have user interface which is block ..
So, how can I put and start Connection in a separate thread in UIThread, and / OnErrorResponse OnResponse () ()
JsonArrayRequest getReq = New JsonArrayRequest (URL, New Response.Listener & lt; JSONArray & gt; () { @Override Public Zero onResponse (JSONArray Feedback) {Log.d ("ONRESPONSE SYNCRO -> Produit", response.toString ()); PgrBarProducts.s EtMax (response.length ()); percentDisplayProduct.setText ("0 /" + PgrBarProducts.getMax ()); nbMaxCallNetwork = PgrBarProducts.getMax (); response.length (try {(for i int = 0 ;; i & Lt); i ++) {JSONObject explrObject = response.getJSONObject (i); string id = integer.tastin (integer) explrObject.get ("id")); CallOnAbject (ID, PGRR Products, Percentage DownloadsProduct, 1); // apple dew product}} hold (jsxexation e) {e.printstaxtress (new print-vaeter (stacktrace)); }}}, New Response.ErrorListener () {@Override Public Zero onErrorResponse (VolleyError Error) {changeStatutToError (); Walliolog D. ("", "Error:" + Error. Short message ()); PercentDisplayProduct.setTextColor (Color.RED); Percent DisplayProduct.SetTipPhase (tap, typeface.ede); PercentDisplayProduct.setText ("Erreur"); WaitBarProgressProduct.setVisibility (View.INVISIBLE); SynchroProducts.setVisibility (View.VISIBLE); }}); GetReq.setRetryPolicy (New DefaultRetryPolicy (60 * 1000, 1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); // Request the request to request queue and start AppController.getInstance (request). AddToAndStartRequestQueue (getReq); }});
Every network request made by volley is done in a background thread, Put behind the scenes There is no need to request a separate thread, because it is already happening.
The listeners, on the other hand, are said to be on the UI thread.
You basically answered your question when you wrote that the data is processed on the UI thread. Just move the data processing that is done to free your UI thread in the background thread / asyncTask
inside your audience and prevents blocking.
Comments
Post a Comment