Given your AsyncTask declaration, you need onProgressUpdate() to accept Void... as a parameter. You can detect this by adding @Override to it.
You might also consider adding @Override to onPostExecute() as well, though your current method signature appears fine. Historically I had been lazy about using @Override, but AsyncTask taught me the (compile) error of my ways... :-) On Mon, Jan 16, 2012 at 2:12 PM, John-Marc Desmarais <[email protected]> wrote: > Hi, > > I have the following AsynchTask class but, it fails to execute the > onProgressUpdate method when doInBackground is running. That is to say > the Log.v(LogName.onProgressUpdate, LogName.onProgressUpdate) never > occurs in LogCat. There are two calls to publishProgress. The first is > after the authentication text view is copied to the instance variable > and second in the update thread. > > Can anyone offer insight? > > public class AuthenticateTask extends AsyncTask<Dialog, Void, Boolean> > { > > private int num_dots; > private boolean firstRun; > private String textToUpdate; > TextView textViewAuthenticating; > Dialog dialog; > > private class LogName > { > public static final String className = "AuthenticateTask"; > public static final String onPreExecute = className + > ".onPreExecute():"; > public static final String doInBackground = className + > ".doInBackground(Dialog...):"; > public static final String onProgressUpdate = className + > ".onProgressUpdate():"; > public static final String onPostExecute = className + > ".onPostExecute(Boolean):"; > } > > protected void onPreExecute() > { > Log.v(LogName.onPreExecute, LogName.onPreExecute); > num_dots = 0; > firstRun = true; > } > > @Override > protected Boolean doInBackground(Dialog... params) > { > Log.v(LogName.doInBackground, LogName.doInBackground); > dialog = params[0]; > textViewAuthenticating = (TextView) > dialog.findViewById(R.id.TextViewAuthentication); > publishProgress(); > Log.v(LogName.doInBackground, LogName.doInBackground + > "dialog: " + dialog); > > Thread updaterThread = new Thread(new Runnable() > { > > public void run() > { > // TODO Auto-generated method stub > try > { > Thread.sleep(250); > } > catch (InterruptedException e) > { > } > finally > { > > AuthenticateTask.this.publishProgress(); > } > } > > }); > > updaterThread.start(); > if (Authenticate()) > { > return true; > } > return false; > } > > protected void onProgressUpdate() > { > Log.v(LogName.onProgressUpdate, LogName.onProgressUpdate); > String tmpString; > dialog.setContentView(R.layout.connnection_progess_dialog); > > if (firstRun) > { > Log.v(LogName.onProgressUpdate, > LogName.onProgressUpdate + "First Run"); > textToUpdate = > textViewAuthenticating.getText().toString(); > Log.v(LogName.onProgressUpdate, > LogName.onProgressUpdate + > "textToUpdate = " + textToUpdate); > firstRun = false; > } > if (num_dots++ == 5) > { > num_dots = 0; > } > tmpString = textToUpdate; > for (int i = 0; i < num_dots; i++) > { > tmpString += " ."; > } > Log.v(LogName.onProgressUpdate, LogName.onProgressUpdate + > "tmpString = " + tmpString); > textViewAuthenticating.setText(tmpString); > } > protected void onPostExecute(Boolean result) > { > Log.v(LogName.onPostExecute, LogName.onPostExecute); > String authentication_finished = > dialog.getContext().getResources().getString(R.string.authentication_finished); > Log.v(LogName.onPostExecute, LogName.onPostExecute + > authentication_finished); > textViewAuthenticating.setText(authentication_finished); > > textViewAuthenticating.setCompoundDrawables(dialog.getContext().getResources().getDrawable(R.drawable.checkmark), > null, null, null); > firstRun = true; > } > > } > > > Regards, > -jm > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in DC: http://marakana.com/training/android/ -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

