Page 1 of 1

cordova-plugin-screensize

Posted: Mon Feb 26, 2018 4:33 pm
by falsam
Practice with Cordova : Get the size of the device screen.

Platform
   Android
   iOS

■ Documentation : https://github.com/pbakondy/cordova-plugin-screensize

Code: Select all

;https://github.com/pbakondy/cordova-plugin-screensize

Declare PluginInit(onSuccess, onError)
Declare successCallback(Result)
Declare errorCallback()

Import "cordova plugin add cordova-plugin-screensize"
EndImport

PluginInit(@successCallback(), @errorCallback()) 

Procedure PluginInit(onSuccess, onError)
  !document.addEventListener("deviceready", function() {
  !  window.plugins.screensize.get(v_onsuccess, v_onerror);
  !});  
EndProcedure

Procedure successCallback(Result)
  Protected Width, Height, Xdpi, Ydpi
  
  !console.log(v_result);
  
  !v_width  = v_result.width
  !v_height = v_result.height
  !v_xdpi   = v_result.xdpi
  !v_ydpi   = v_result.ydpi  
  
  Debug DeviceInfo(#PB_Device_Platform) + " - Version " + DeviceInfo(#PB_Device_Version)
        
  Debug "Dimension " + Str(Height) + " / " + Str(Width)
  Debug "Pixel per inch X:" + StrF(Xdpi, 3) + " dpi Y:" + StrF(Ydpi, 3) + " dpi"
EndProcedure

Procedure errorCallback()
  Debug "error"
EndProcedure
Create your package and run.
Debug wrote: Android - Version 5.1
Dimension 720 / 1196
Pixel per inch X:326.571 dpi Y:328.404 dpi

Re: cordova-plugin-screensize

Posted: Tue Feb 27, 2018 6:37 pm
by plouf
works perfect .... have to "enable debugger" in local apps..