【问题标题】:Put certain conditions on device version of device in phonegap Android Application在phonegap Android应用程序中对设备的设备版本设置某些条件
【发布时间】:2013-09-17 18:47:11
【问题描述】:

如何根据设备操作系统版本在 phonegap android 应用程序中设置某些条件。就像我尝试过的一样:-

deviceVersion = device.version;

if (deviceVersion > 2.3){....

        } else {
            ......  
    } 

但这不适用于真实设备,因为设备版本类似于 4.0.2 等。

有什么解决办法吗?

【问题讨论】:

    标签: android cordova


    【解决方案1】:

    试试这个..

        var ua = navigator.userAgent;
        if( ua.indexOf("Android") >= 0 )
        {
          var androidversion = parseFloat(ua.slice(ua.indexOf("Android")+8)); 
          if (androidversion < 2.3)
          {
              // do whatever
          }
        }
    

    Detecting the OS version of iOS and Android in the browser

    【讨论】:

    • 这里你使用了 userAgent 但是我们可以使用 device.version 这个
    猜你喜欢
    • 2013-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多