How do I disable Android @IntDef annotation checks in special cases?
I've found the way to suppress the annotation checks. Actually, there are three of them:
Add
@SuppressWarnings("ResourceType")
before the definition of your class. In my case:@SuppressWarnings("ResourceType")public class MainActivity extends ActionBarActivity { ...}
Add
@SuppressWarnings("ResourceType")
before the definition of your method. In my case:@Override@SuppressWarnings("ResourceType")protected void onCreate(Bundle savedInstanceState) { ...}
These two approaches do not work for me, because I want annotation checks on all of my code, except for just one statement.
To suppress a check on a single line add a specially formatted comment (!!!).
//noinspection ResourceTypefState = savedInstanceState.getInt(BUNDLE_STATE);
@Status int state1=bundle.getInt(STATE_ELEMENT1);setStatus1(state1);//instead of direct setStatus1(bundle.getInt(STATE_ELEMENT1);