不同的Java方法针对不同的API级别不同、级别、方法、Java

2023-09-07 13:04:34 作者:男人再拽姐照样甩

您如何使每个部分版本不同的API级别的方法。我认为这是这样的事情,但我不知道

How can you make a method with some versions each for a different API level. I think it's something like this, but I'm not sure

@apilevel("11")
private void getR()
{
...
}

@apilevel("4")
private void getR()
{
...
}

什么是做这种正确的方法是什么?在此先感谢

What is the correct way to do this? Thanks in advance

推荐答案

您可以使用:

Integer.valueOf(android.os.Build.VERSION.SDK);

有关引用您可能要检查这里: HTTP:/ /developer.android.com/reference/android/os/Build.VERSION.html#SDK

For reference you may like to check here: http://developer.android.com/reference/android/os/Build.VERSION.html#SDK

而对于自己的水平在这里是列表: HTTP: //developer.android.com/guide/topics/manifest/uses-sdk-element.html

And for the levels themselves here is the list: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

 
精彩推荐
图片推荐