cordova-plugin-screensize

Share your advanced knowledge/code with the community.
falsam
Posts: 280
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

cordova-plugin-screensize

Post 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

➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
http://falsam.com

Sorry for my poor english
plouf
Posts: 194
Joined: Tue Feb 25, 2014 6:01 pm
Location: Athens,Greece

Re: cordova-plugin-screensize

Post by plouf »

works perfect .... have to "enable debugger" in local apps..
Christos
Post Reply