Is it possible to annotate method to run code in UiThread?
runOnUiThread(new Runnable() {
public void run() {
//my code
}});
looks too complex to use it often.
Look at the AndroidAnnotations project. They use a annotations. As far as i know it is what you want. It uses compile time code generation http://code.google.com/p/androidannotations/
According to the documentation the @UiThread
annotation only denotes that the given class/method should run on the UI thread. It does NOT mean using this annotation will call your method on the UI thread.
Edit: this answer is not relevant any more. You can annotate with @UiThread
.
According to Google IO 2015, @UiThread
is the annotation you are looking for. There will be actually four new:
http://robovm.com/google-io-summary-whats-new-in-android-development-tools/ (under New Support Annotations).
Sadly, they are not live yet. When they will be live, they will pop up in here: https://developer.android.com/reference/android/support/annotation/package-summary.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With