java - How to display the ProgressDialog when do network operations using volley -
i woking on android application interested use volley
library perform network http calls.
but question found library operations in different background thread how can showprogressdialog
when http request start execute later dismiss once has executed.
requestqueue rq = volley.newrequestqueue(this); stringrequest postreq = new stringrequest(request.method.post, "http://httpbin.org/post", new response.listener<string>() { @override public void onresponse(string response) { tv.settext(response); // set response data in textview } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { system.out.println("error ["+error+"]"); } });
thanks in advance.
it's pretty straight forward. start progress dialog once add request object in queue.
//add request queue rq.add(request); //initialize progress dialog , show progressdialog = new progressdialog(getactivity()); progressdialog.setmessage("fetching file...."); progressdialog.show();
then dismiss dialog once have received response server.
stringrequest postreq = new stringrequest(request.method.post, "http://httpbin.org/post", new response.listener<string>() { @override public void onresponse(string response) { tv.settext(response); // set response data in textview progressdialog.dismiss(); } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { log.e(“volly error”,”error: ”+error.getlocalizedmessage()); progressdialog.dismiss(); } });
Comments
Post a Comment