This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
sample_code:get_device_specs [2015/01/17 20:39] stevegarman created |
sample_code:get_device_specs [2015/12/18 21:50] administrator remove confusing comment |
||
---|---|---|---|
Line 8: | Line 8: | ||
<code JavaScript getDeviceSpecs.js> | <code JavaScript getDeviceSpecs.js> | ||
+ | var allBuilds = JSON.parse(' | ||
+ | '" | ||
+ | '" | ||
+ | '" | ||
+ | '" | ||
+ | '" | ||
+ | '" | ||
+ | '" | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | var osObj = allBuilds[app.GetOSVersion()] | ||
+ | try | ||
+ | { | ||
+ | var osInfo = " | ||
+ | osObj.codename + " | ||
+ | osObj.level | ||
+ | } | ||
+ | catch(err) | ||
+ | { | ||
+ | var osInfo = app.GetOSVersion(); | ||
+ | } | ||
// | // | ||
function OnStart() | function OnStart() | ||
{ | { | ||
+ | |||
// | // | ||
- | lay = app.CreateLayout( " | + | var lay = app.CreateLayout( " |
// | // | ||
- | btn = app.CreateButton( " | + | var btn = app.CreateButton( " |
btn.SetOnTouch(btn_OnTouch); | btn.SetOnTouch(btn_OnTouch); | ||
lay.AddChild( btn ); | lay.AddChild( btn ); | ||
Line 36: | Line 74: | ||
var model = app.GetModel(); | var model = app.GetModel(); | ||
var tablet = app.IsTablet(); | var tablet = app.IsTablet(); | ||
+ | var fromapk = ( app.GetAppPath() == "/ | ||
+ | var dsversion = app.GetDSVersion(); | ||
// | // | ||
var sw = app.GetScreenWidth(); | var sw = app.GetScreenWidth(); | ||
Line 43: | Line 83: | ||
var dw = app.GetDisplayWidth(); | var dw = app.GetDisplayWidth(); | ||
var dh = app.GetDisplayHeight(); | var dh = app.GetDisplayHeight(); | ||
+ | // | ||
+ | var intfld = app.GetInternalFolder(); | ||
+ | var extfld = app.GetExternalFolder(); | ||
+ | var intspace = app.GetFreeSpace(" | ||
+ | var extspace = app.GetFreeSpace(" | ||
+ | |||
// | // | ||
// | // | ||
- | var s = "/ | + | try {os=osInfo; |
+ | catch(err){} | ||
+ | var s = "/ | ||
+ | " | ||
" | " | ||
" | " | ||
+ | " | ||
" | " | ||
" | " | ||
" | " | ||
" | " | ||
- | " | + | " |
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
return(s); | return(s); | ||
} | } | ||
- | |||
</ | </ | ||
===== Notes ===== | ===== Notes ===== | ||
The function getDeviceSpecs at the end of the code, can be pasted independently into a project an the string returned can be used however you see fit. | The function getDeviceSpecs at the end of the code, can be pasted independently into a project an the string returned can be used however you see fit. |