Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@UiThread pre/post Execute

With android-annotations I can replace AsyncTask<Param, Progress, Result> with @UiThread.

But is possible to handle something like onPreExcecute / onPostExecute of AsynkTask?

like image 755
gipinani Avatar asked Mar 27 '26 10:03

gipinani


1 Answers

There is no callback methods to handle this. But you can have the same result by calling methods at the beginning and at the end of your @Background annotated method (you said @UIThread but I hope this was a mistake :)).

Example :

@Background
void longRunningProcess() {
    longRunningProcessStarted();
    //...
    longRunningProcessEnded();
}

@UiThread
void longRunningProcessStarted() {

}

@UiThread
void longRunningProcessEnded() {

}

We also wrote a cookbook about this.

like image 77
DayS Avatar answered Apr 02 '26 11:04

DayS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!