Check if there is Android version 4 with telephony?

I am trying to check if Android version is less than 4 with telephony.

I am getting a version with this.

   var deviceOS  = device.platform;  //fetch the device operating system
   var deviceOSVersion = device.version;  //fetch the device OS version
          alert("Device OS: " + deviceOS); 
          alert("Device OS Version: " + deviceOSVersion);

      

And trying to check if version is different from 4 but it doesn't work?

if (deviceOSVersion < 4) {
    alert("android less than 4");
}

      

I've tested a few things but no luck.
Anyone introduce thanks.

UPDATE: I am trying to set the last "useAnimations: animationen" code to false if present and android is less than 4 and if it is iPhone the "animation" should be true. But on iPhone, is it wrong with the below code?

 var int = 0;
    var animationen='';

  function onBodyLoad()
        {         
       document.addEventListener("deviceready", onDeviceReady, false);
        }

        function onDeviceReady()
        {
    getDeviceProperty();
        }

    function getDeviceProperty(){
     var deviceOS  = device.platform;  //fetch the device operating system
     var deviceOSVersion = device.version;  //fetch the device OS version
          alert("Device OS: " + deviceOS); 
          alert("Device OS Version: " + deviceOSVersion); 


if (deviceOS.indexOf('Android') >= 0) {
alert("its an android");
int = parseInt(deviceOSVersion);
if(int<4){
alert("animation false");
animationen=false;
}
alert("apptype = android");
}
else
{
alert("apptype = iphone");
animationen=true;
}                     
}


var jQT = new $.jQTouch({
useAnimations: animationen
});

      

+3


source to share


2 answers


You need to parse the value obtained with

if( parseInt( deviceOSVersion, 10 ) < 4 )
{
    // your code
}

      



Hope it helps

+4


source


var int = 0;  
....// your code here
int = parseInt(deviceOSVersion);
if(int<4){
//do something
}

      



I have checked and it works.

+1


source







All Articles