Kony-Device Information Reading Programmatically
1. Example :
function ostypeINFO()
{
var types = kony.os.deviceInfo().name;
alert("Os Type : "+types);
var widthandheight = kony.os.deviceInfo().deviceHeight+"x"+kony.os.deviceInfo().deviceWidth;
alert("device widthx Height : "+widthandheight);
var model = kony.os.deviceInfo().model;
alert("deive model : "+model);
var version = kony.os.deviceInfo().version;
alert("device version : "+version);
}
2. Example : Device Information
function isDeviceinfomation(){
var deviceINFO = kony.os.deviceInfo();
alert("Device Information : "+JSON.stringify(deviceINFO));
}
var deviceINFO = kony.os.deviceInfo();
alert("Device Information : "+JSON.stringify(deviceINFO));
}
Javascript compiler : http://rextester.com/l/js_online_compiler
Method : 1
function jsonParser() {
var result = {
"name": "android",
"deviceHeight": "1184",
"deviceWidth": 720,
"model": "T04",
"version": "5.1"
};
var jsonParse = JSON.parse(JSON.stringify(result));
var res = jsonParse["name"];
print("name : " + jsonParse["name"]);
print("deviceHeight : " + jsonParse["deviceHeight"]);
print("deviceWidth : " + jsonParse["deviceWidth"]);
print("model : " + jsonParse["namemodel"]);
print("version : " + jsonParse["version"]);
}
Method 2 :
function jsonParser() {
var jsonParse = JSON.parse('{"name":"android","deviceHeight":"1184","deviceWidth":720,"model":"T04"
,"version":"5.1"}');
print("name : " + jsonParse.name);
print("deviceHeight : " + jsonParse.deviceHeight);
print("deviceWidth : " + jsonParse.deviceWidth);
print("model : " + jsonParse.namemodel);
print("version : " + jsonParse.version);
}
Method : 3
function jsonParser()
{
var result = {"name":"android","deviceHeight":1184,"deviceWidth":720,"model":"T04","version":"5.1"}
var jsonParse = JSON.parse(JSON.stringify(result));
print("name : "+jsonParse.name);
print("deviceHeight : "+jsonParse.deviceHeight);
print("deviceWidth : "+jsonParse.deviceWidth);
print("model : "+jsonParse.namemodel);
print("version : "+jsonParse.version);
}
Method : 4
function jsonParser() {
var result = {
"name": "android",
"deviceHeight": 1184,
"deviceWidth": 720,
"model": "T04",
"version": "5.1"
}
var jsonParse = eval("(function(){return" + JSON.stringify(result) + "})()");
print("name : " + jsonParse.name);
print("deviceHeight : " + jsonParse.deviceHeight);
print("deviceWidth : " + jsonParse.deviceWidth);
print("model : " + jsonParse.namemodel);
print("version : " + jsonParse.version);
}
jsonParser();
Output :
name : android
deviceHeight : 1184
deviceWidth : 720
model : undefined
version : 5.1
Output Screen :-
2.Example : Device ID (Device Model )
//fetching Device model for an android device
function deviceUserUrgent() {
var devID = kony.os.userAgent();
alert("User Agent return value is::" + devID);
}
3. Example : Device Memory space
//fetching available space on device for application installation purpose
function fetchFreeMry() {
var freememory = kony.os.freeMemory();
alert("Result : " + freememory);
}
var freememory = kony.os.freeMemory();
alert("Result : " + freememory);
}
//calculate bytes ;
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return '0 Byte';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
};
bytesToSize(126103348);
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return '0 Byte';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
};
bytesToSize(126103348);
Result : 121 MB
4. Example : Camera Support
//checking camera support on device
function deviceCameraSupport(){
var camera_support = kony.os.hasCameraSupport();
alert("Result : "+camera_support);
}
Output Screen :-
5. Example : GPS Support
//checking gps availability support
function checkGPSSupport() {
var checkgpsSupport = kony.os.hasGPSSupport();
alert("GPS Support ==> " + checkgpsSupport);
}
Output Screen :-
var checkgpsSupport = kony.os.hasGPSSupport();
alert("GPS Support ==> " + checkgpsSupport);
}
Output Screen :-









