Android@TargetApi返回
我正在为api 19使用布尔返回类型的方法,而我的应用程序支持min sdk 15,如果api小于19,该方法将返回什么Android@TargetApi返回,android,annotations,Android,Annotations,我正在为api 19使用布尔返回类型的方法,而我的应用程序支持min sdk 15,如果api小于19,该方法将返回什么 @TargetApi(19) public static boolean isFeatureXEnabled(Context context) { some logic return true/false; } API的回报是什么?让我们了解一下@TargetApi(19) 您使用的功能在minimum SDK上不可用,因此 Compiler :
@TargetApi(19)
public static boolean isFeatureXEnabled(Context context) {
some logic
return true/false;
}
API的回报是什么?让我们了解一下
@TargetApi(19)
您使用的功能在minimum SDK上不可用,因此
Compiler : you cannot use this feature , it is not supported by min sdk
You: i know what i am doing so hush , take this @TargetApi(19)
Compiler : so now it is your responsibility to check the API level and call this function accordingly
如果api小于19,该方法将返回什么
如果minsdk不支持此函数中的代码,则很可能发生崩溃,否则会导致逻辑计算的结果
你可以这样做
@TargetApi(19)
public static boolean isFeatureXEnabled(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
some logic
return true/false;
}
return false;
}
让我们了解一下
@TargetApi(19)
您使用的功能在minimum SDK上不可用,因此
Compiler : you cannot use this feature , it is not supported by min sdk
You: i know what i am doing so hush , take this @TargetApi(19)
Compiler : so now it is your responsibility to check the API level and call this function accordingly
如果api小于19,该方法将返回什么
如果minsdk不支持此函数中的代码,则很可能发生崩溃,否则会导致逻辑计算的结果
你可以这样做
@TargetApi(19)
public static boolean isFeatureXEnabled(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
some logic
return true/false;
}
return false;
}
@TargetApi 指示Lint应将此类型视为以给定API级别为目标,无论项目目标是什么-
这意味着Lint仅使用它来隐藏/抑制警告。它对返回值有何影响。@TargetApi 指示Lint应将此类型视为以给定API级别为目标,无论项目目标是什么- 这意味着Lint仅使用它来隐藏/抑制警告。它在返回值中具有ho效应