java - ProgressBar is not stopped after Completing Background Execution in Android -


itemprop = "text">

I am working in Android technology. In my application, I am bringing data from the web service. Service. It is true that there is a wrong data on the toast or the right but my progress bar continues to run, when the background work is completed its execution, then I dismissed the method in the transmitted piecetext (). But it failed to dismiss the progress bar.

Can you tell me what I did wrong in my code. Please solve my problem ..

I am attaching source code here

async work

  public class MyTask AsyncTask and lt; String, zero, string & gt; {@Override protected void onPostExecute (string result) {// TODO automatically generated method stub super.onPostExecute (results); Pd.dismiss (); Toast. Make text (getApplicationContext (), "" + result, toast.lNGTH_LONG) .show (); } @ Override Protected Zero on PreExecute () {// TODO Automatically generated method stub super.onPreExecute (); PD = new progress DIOL Ogh (main activity.); Pd.setMessage ("Please Wait"); Pd.setCancelable (wrong); Pd.setIndeterminate (wrong); Pd.show (); } @ Override protected string doInBackground (string ... arg0) {// TODO auto-generated method stub V = new valid (); String result; Results = v.SendParam (URL, user, passed); Return result; }}  

ID valid here. Java code

  class valid {ArrayList & lt; NameValuePair & gt; Namevaluepair; InputStream is; String rays; Send Public StringParam (String URL, String Username, String Password) {Try {HTTP Client Client = New Default HTTP Client}; HTTP Post Post = New HTTP Post (URL); // add parameter here namevaluepair = new ArrayList & lt; NameValuePair & gt; (); Namevaluepair.add (new BasicNameValuePair ("id", user name)); Namevaluepair.add (New BasicNameValuePair ("password", password)); Post.setEntity (new UrlEncodedFormEntity (namevaluepair)); HttpResponse response = client.execute (post); HttpEntity unit = response.getEntity (); Is = entity.getContent (); } Hold (exception e) {log d. ("Http connection", "error", e); } // Read the answer from the attempt {BufferedReader Reader = New BufferedReader (New InputStreamRadder ("ISO-885 9-1"), 8); Stringbuilder builder = new stringbiller (); String line; While ((line = reader. Readline ()) = null) {builder.append (row + "\ n"); }               is close(); Race = builder.toString (); } Hold (exception e) {log d. ("Reading input stream", "", e); } Return Ridge; }}  

Your code should work fine (problems without being dismissed without problems needed).
However, I'm guessing that your posted method is throwing an error, and therefore the onPostExecute has not reached the method. Change doInBackground to your code:

  @Override protected string doInBackground (string ... arg0) {try {v = new validate ()} string result; Results = v.SendParam (URL, user, passed); Return result; } Hold (exception e) {e.printStackTrace (); } Return tap; }  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -