-
Notifications
You must be signed in to change notification settings - Fork 0
WorkingWithThreads
Since AndroidAnnotations 1.0
Get rid of AsyncTasks!!
The @Background
annotation indicates that an activity method will run in a thread other than the ui thread.
The method must not be private and must not declare throwing any exception.
Usage example:
void myMethod() {
someBackgroundWork("hello", 42);
}
@Background
void someBackgroundWork(String aParam, long anotherParam) {
[...]
}
the method is executed on a separate thread, but this doesn't necessarily mean that a new thread will be started, because we use a shared cached thread pool executor (which can be replaced) to prevent creating too much threads.
The @UiThread
annotation indicates that an activity method will run in the ui thread.
The method must not be private and must not declare throwing any exception.
Usage example:
void myMethod() {
doInUiThread("hello", 42);
}
@UiThread
void doInUiThread(String aParam, long anotherParam) {
[...]
}
@UiThreadDelayed
is deprecated as of version 2.5. You should use@UiThread(delay="2000")
instead.
The @UiThreadDelayed
annotation indicates that an activity method will run in the ui thread, after the specified amount of time elapses.
The method must not be private and must not declare throwing any exception.
Usage example:
void myMethod() {
doInUiThreadDelayed("hello", 42);
}
@UiThreadDelayed(2000)
void doInUiThreadDelayed(String aParam, long anotherParam) {
[...]
}
No more AsyncTask<Param, Progress, Result>
!!
AndroidAnnotations was created by Pierre-Yves Ricau and is sponsored by eBusinessInformations.
09/11/2014 The 3.2 release is out !
- Get started!
- Download
- Cookbook, full of recipes
- Customize annotation processing
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow