Android / Java: onProgressUpdate () not being called?

I read related topics here, even googled, but without a solution.

onProgressUpdate () is simply not being called.

Here is the code:

public class DoHardWork extends AsyncTask { @Override protected Object doInBackground(Object... params) { publishProgress("Requesting XML data"); this.requestData(); publishProgress("Returning results"); this.returnResults(); return null; } protected void onProgressUpdate(String text) { super.onProgressUpdate(text); MainActivity.setLog(text); } } 

I tried to set a breakpoint in onProgressUpdate () and it was never called. This is how the code is simply ignored.

Someone had a similar problem, and it turned out that just the eclipse was just messing with him, but I tried to restart it without success.

Any ideas?

+6
source share
1 answer

I think you missed something in your code. Try with this:

 private class DoHardWork extends AsyncTask<Void, String, Long> { protected Long doInBackground(Void... urls) { publishProgress("Requesting XML data"); this.requestData(); publishProgress("Returning results"); this.returnResults(); return null; } protected void onProgressUpdate(String... progress) { super.onProgressUpdate(progress); MainActivity.setLog(progress[0]); } } 
+11
source

Source: https://habr.com/ru/post/916377/


All Articles