Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

低版本SDK如何实现高版本api? #124

Open
Sogrey opened this issue Apr 27, 2019 · 0 comments
Open

低版本SDK如何实现高版本api? #124

Sogrey opened this issue Apr 27, 2019 · 0 comments
Labels
Android android相关

Comments

@Sogrey
Copy link
Owner

Sogrey commented Apr 27, 2019

使用@TargetApi注解·

当代码中有比AndroidManifest中设置的android:minSdkVersion版本更高的方法,此时编译器会提示警告,解决方法是在方法上加上@SuppressLint("NewApi")或者@TargetApi()。但它们仅是屏蔽了android lint错误,在方法中还要判断版本做不同的操作。

@SuppressLint("NewApi")屏蔽一切新api中才能使用的方法报的android lint错误

@TargetApi() 只屏蔽某一新api中才能使用的方法报的android lint错误,如@TargetApi(11)如果在方法中用了只有API14才开始有的方法,还是会报错。

@Sogrey Sogrey added this to 系统适配 in android相关 Sep 17, 2019
@Sogrey Sogrey added the Android android相关 label Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android android相关
Projects
android相关
系统适配
Development

No branches or pull requests

1 participant