Android 如何使用来自其他类的IntDef注释
我正在尝试使用android.content.pm.ActivityInfo中的Android 如何使用来自其他类的IntDef注释,android,android-support-library,Android,Android Support Library,我正在尝试使用android.content.pm.ActivityInfo中的@ScreenOrientation。其宣言: @IntDef({ SCREEN_ORIENTATION_UNSPECIFIED, SCREEN_ORIENTATION_LANDSCAPE, ... }) @Retention(RetentionPolicy.SOURCE) public @interface ScreenOrientation {} 如果我这样使用它
@ScreenOrientation
。其宣言:
@IntDef({
SCREEN_ORIENTATION_UNSPECIFIED,
SCREEN_ORIENTATION_LANDSCAPE,
...
})
@Retention(RetentionPolicy.SOURCE)
public @interface ScreenOrientation {}
如果我这样使用它,编译器无法解析它:
public abstract class ActivityBase extends ActionBarActivity {
@ScreenOrientation
protected abstract int getPhoneOrientation();
}
导入android.content.pm.ActivityInfo.*代码>没有帮助。
@android.content.pm.ActivityInfo.ScreenOrientation
也没有帮助
我在gradle文件中有注释库
compile 'com.android.support:support-annotations:22.0.0'
是否可能,或者注释只是以某种方式隐藏?注释确实是隐藏的-如果您查看ActivityInfo
(当前第313行):
你会看到它上面有一个@hide
注释,从而阻止我们在应用程序中直接使用它。后期建议:你的目标是哪些SDK?屏幕方向的intdef自版本5.0.0起就在源代码中,而不是之前的版本。也许这就是问题所在。@funglejunktargetSdkVersion 22