How to use Spinning or Wait icon when AsyncTask is being performed in Android? -
I have used AsyncTask to retrieve data from my web services I want to show some spinning or waiting icon masking While the webservice is being processed. I have seen some solutions about this but they are too long to write, I do not need to show how many percentages remain for full processing, I just want to show an icon on the processing of web service and execute it Should be rejected at the time. I'm calling this code from my activity and I want to show an icon on my activity. See my code below Please suggest some small and easy solution.
Public class AsyncLoginWarden AsyncTask and lt; String, integer, string & gt; {Secure string doInBackground (string ... str) {webserviceCall wb = new WebserviceCall ()); Wb.param1 = str [0]; Wb.param2 = str [1]; String response = wb.LoginWarden ("LoginWarden"); Return feedback; } PostExecute at safe zeros (string result) {System.out.println ("successfully logged in" + result); }} Updated code
package com.example.trafficviolationreporter; Import android.app.ProgressDialog; Import android.content.Context; Import android.os.asyncTask; Public category of asynchronous engineering async Task and Late; String, integer, string & gt; {Progress DIOLOG PD; With reference; Main activity ma; String user name, password; Public Aynchronology Warden (Main Activity Ma, String Username, String Password) {this.ma = ma; This.co = Ma; this.password = password; This.username = Username; PD = new progression Diallog (co); } @ Override Preserve Zero on Prextec () {this.pd.show (); super.onPreExecute (); } Protected string doInBackground (string ... str) {webserviceCall wb = new WebserviceCall ()); Wb.param1 = str [0]; Wb.param2 = str [1]; String response = wb.LoginWarden ("LoginWarden"); Return feedback; } Zero on Strings (string result) {System.out.println ("Successfully logged in" + result); Pd.dismiss (); }}
You can create progress dialogues in the past of your async class and dismiss it Async Class's OnPostexute here is how you would do this:
Public class AsyncLoginWarden AsyncTask & lt; String, integer, string & gt; {Progress DIOLOG PD; With reference; Your activity; String user name, password; Public Asynchronous Warden (Your Activity Ma, String Username, String Password) {this.ma = ma; This.co = Ma; This.password = password; This.username = Username; PD = new progression Diallog (co); pd.setTitle ("title"); Pd.setMessage ("message"); } @ Override Preserve Zero on Prextec () {this.pd.show (); super.onPreExecute (); } Protected string doInBackground (string ... str) {webserviceCall wb = new WebserviceCall ()); Wb.param1 = str [0]; Wb.param2 = str [1]; String response = wb.LoginWarden ("LoginWordon"); Return feedback; } Zero on Strings (string result) {System.out.println ("Successfully logged in" + result); Pd.dismiss (); }} Call your async class from the activity:
your activity = this; New AsyncLoginWarden (Ma, Username, Password). Execute ();
Comments
Post a Comment