How to run the same asynctask more than once?

前端 未结 12 2087
难免孤独
难免孤独 2020-12-01 03:32

I have my asyncTask run when the activity first starts, then if network connectivity is not available then i have a refresh button that tries to run the asyncTask to try aga

12条回答
  •  生来不讨喜
    2020-12-01 03:59

    You could cancel your asyncTask when you press the button and then execute it again.

    Inside OnClic method:

    asyncTask.cancel();
    AsyncTask asyncTask = new AsyncTask();
    asyncTask.execute();
    

提交回复
热议问题