I want to use Java annotations to insert code (method invocations and so on). Let's say I have such code:
ActionBar bar = getActionBar();
assert bar != null;
bar.setIcon(android.R.color.transparent);
EventBus.getDefault().register(this);
checkGPS();
This code appears in each my Activity class. And instead of writing it each time I want to have something like this : @PrepareActivity
which will expand code. In C or C++ I can simply use #define PrepareActivity \ ...
. Can I write the same with Java annotations? And how to do this? Thanks.