Android:在运行时获取TargetSDKVersion [英] Android: Get TargetSDKVersion in runtime

查看:109
本文介绍了Android:在运行时获取TargetSDKVersion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在运行时获取使用过的TargetSDKVersion吗?

Can I get the used TargetSDKVersion in runtime?

这是由于以下事实:Android API 19>中的WebView处理像素的方式与pre 19不同.

This is due to the fact that the WebView in Android API 19> handles pixels differently than pre 19.

这是一个库,所以我不想让开发人员手动输入它.

This is for a library and so I would not like to have the developer enter it manually.

我的评论:我正在使用Nexus 5 API 21棒棒糖.更改TargetSDKVersion会将html的javascript读取宽度的方式更改为屏幕密度的倍数.我刚刚将其更改为14,然后更改为19,我确认了这一点.

My comment: I am using my Nexus 5 API 21 Lollipop. Changing TargetSDKVersion changes the way javascript of the html reads the widths by a multiple of the screen density. I have just changed it to 14 then to 19, and I confirm this.

推荐答案

OR

如果我们谈论设备操作系统版本

If we talk about device OS version

构建类包含有关版本的信息

android.os.Build.VERSION.SDK_INT

这篇关于Android:在运行时获取TargetSDKVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆