Is it possible to annotate a method to run code in UiThread?
runOnUiThread(new Runnable() { public void run() { //my code }});
It looks too complicated to use it often.
Take a look at the AndroidAnnotations project. They use annotations. As far as I know, this is what you want. It uses compilation time generation http://code.google.com/p/androidannotations/
According to the documentation, the @UiThread annotation @UiThread means that the given class / method should work on the user interface thread. It does NOT mean that using this annotation will call your method in the user interface thread.
@UiThread
Edit: This answer is no longer relevant. You can annotate with @UiThread .
According to Google IO 2015, @UiThread is the annotation you are looking for. There will actually be four new ones: http://robovm.com/google-io-summary-whats-new-in-android-development-tools/ (in the "New Support Annotations" section).
Unfortunately, they do not yet live. When they live, they will appear here: https://developer.android.com/reference/android/support/annotation/package-summary.html
@UiThreadTest now works. I am sure this will be obsolete for the real thing soon, so caution emptor.