I try to create a method which returns me the screenorientation dependend on wether the Device is a handheld or a tablet.
public int getScreenOrientation(boolean isTablet){
if(isTablet){
return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
} else {
return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}
}
But when I use setRequestedOrientation(getScreenOrientation));
I get a lint-error Must be one of: ActivityInfo.SCREEN_ORIENTATION_.........
which I can suppress, but that doesn't look like clean code.
So I found, that getRequestedOrientation
uses the @ActivityInfo.ScreenOrientation
Annotation. So I tried to use it myself:
@ActivityInfo.ScreenOrientation
public int getScreenOrientation(boolean isTablet){
.
.
.
}
But the IDE gives me an error stating that the Annotation @ActivityInfo.ScreenOrientation
could not be found. But it is declared public in the official-android-source.
Put the following comment above the annoying statement where the magic constant inspection for @IntDef and @StringDef annotation is triggered, for example:
//noinspection ResourceType
setRequestOrientation(lock);
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