Starting a new operation in doInBackGround () AsyncTask

In my project, I need to call a request for user action every 1 hour. This should be done in AyncTask (in fact, I am modifying existing code). Can I start a new activity at doInBackGround () AsyncTask? Thanks in advance!

+4
source share
2 answers

I do not think that you can start your activity directly from the doInBackground () method, since it works in a different thread than the UI thread. I think the action should start in the user interface thread. But you can probably run it on onProgressUpdate (), which runs in the user interface thread.

+4
source

In onPostExecute you can start a new activity, do not try to start the activity in doInBackground, but it seems possible.

0
source

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


All Articles