Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android@TargetApi返回_Android_Annotations - Fatal编程技术网

Android@TargetApi返回

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 :

我正在为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 : 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效应