This guide explains "Device" object which gives information about the device used.
There are 8 methods about Device and these are ;
canOpenurl : Returns whether an app can open a given URL resource. Returns true if it can open or returns false if it cannot open.
getPackageInfo : This method is available for Android only. Returns versionName value of Android getPackageManager().getPackageInfo() method.
isApplicationInstalled : Returns an application with given package name is installed on device. Returns true if it is installed or returns false if it is not installed.
makeCall: Calls the given phone number.
setAccelerometerStatus : Enables to set whether accelerometer status open or not.
setGPSStatus : Enables to set whether GPS status open or not.
vibrate : Runs the device vibrate property on or off. This action is used to vibrate the handset for given time period in milliseconds.
captureScreen: Used to get screen capture of device. Returns "e.path" value which gives the captured image’s path. You can use it directly by giving this path to an image object. captureScreen method has 5 input parameters:
If rectangle is not provided, it gets the entire screenshot as in the below example.
Let's use a label to show "e.path" value, an image object to show the captured image and a button to trigger captureScreen method.
As you see in the code above, the label will show on top of the page, below that there will be an image object, and at the buttom there will be a textButton object.
- At first it will look like as in the 1 picture above.
- When pressed “Capture Screen” button for once, it will look like as in the 2nd picture.
- And others are the view of other presses.
In the above example, no rectangle was set. Now let's use captureScreen method by setting rectangle and see the result.
Because we set rectangle’s top and left 0, method took the screenshot beginning from 0,0 point on screen, and the result looks like as in the screenshot.
"Device" has 37 properties, please refer to the API Docs.
There are 3 events for a device and these are ;
onAccelerate : Creates action(s) that are run when Accelerometer detect a change.
onConnectionTypeChanged : Creates action(s) that are run when type of the network connection changed.
onLocationChanged : Creates action(s) that are run when location changed.