Native Mobile Utils API

Utils External Object

"SmartDevicesPlusUtil" or "WorkWithPlusNMUtils" in newer versions, is an External Object that contains methods than can be used to simplify some tasks that are necessary in most projects. This External Object is imported into the Knowledge Base when you run the "Design System Wizard" and will be available so you can easily use it:

SmartDevicesPlusUtilsImg01

Newer versions:

Method  
ToggleAndroidChartsScroll WorkWithPlusNMUtilsImg01
ToggleAndroidUCScroll
TakeScreenshot
SetScreenBrightness
GetScreenBrightness
TurnOffSleepMode
TurnOnSleepMode
TurnOnShake
TurnOffShake
TurnOnScreenRecording
TurnOffScreenRecording
GetPixelsFromDips
GetDipsFromPixels
GetScreenWidth
GetScreenHeight
ParseHexColor
GetHexFromDecimal
GetDecimalFromHex
OnShake

 

ToggleAndroidChartsScroll and ToggleAndroidUCScroll methods are deprecated.

TakeScreenshot:

This method lets the user take a screenshot with a specific width and height so you can customize the resolution of the image. If the width and height are left in 0, the image from the screenshot will have the resolution of the device.

If you set whether the width or the height (and leave the other value in 0) the image from the screenshot will be adjusted to keep the proper resolution.

Disable screenshots:

TurnOnScreenRecording and TurnOffScreenRecording can be used to disable application screenshots.

This functionality is currently only available in Android.

To use this functionality, you must invoke these methods at the time you need:

DisabledScreenCapturesImg02

This could be useful in screen in which you handle sensitive data.

GetPixelsFromDips

Converts a size from dips to pixels, considering current device screen density.

GetDipsFromPixels

Converts a size from pixel to dips, considering current device screen density.

GetScreenWidth

Returns current device screen width in pixels.

GetScreenHeight

Returns current device screen height in pixels.

ParseHexColor

Take the hexadecimal value, transforms it to decimal and separates it into RGB colors.

GetHexFromDecimal

Converts a hexadecimal value to decimal.

GetDecimalFromHex

Converts a decimal value to hexadecimal.

ImageToBase64:

Deprecated: Newer versions use it from ImageManipulation: ImageToBase64.

This method let convert an image to Base64.

ImageFromBase64:

Deprecated: Newer versions use it from ImageManipulation: ImageFromBase64.

This method let convert Base64 string to an image.

Avoid screen blocking:

Deprecated: As of GenXus 18 Upgrade 13 this functionality is provided natively by GeneXus

TurnOffSleepMode and TurnOnSleepMode can be used to turn on or off the phone's "sleep mode" to prevent screen blocking.

This functionality is currently only available in Android.

e.g.:

AvoidScreenBlockingImg02

Change screen brightness:

Deprecated

SetScreenBrightness and GetScreenBrightness can be used to change the phone's screen brightness.

This functionality is currently only available in Android. Requires user to manual modify the "AndroidManifest.xml" file, to add the following permission: <uses-permission android:name="android.permission.WRITE_SETTINGS" />

For example, if you want to change the screen brightness to the max value and then change it back in another moment, you only need to do the following:

ChangeScreenBrightnessImg02

Detecting phone's shake:

Deprecated

You can use a method to detect when the user "shakes" the phone. This can be used to execute any action, for example, change current page, play a sound, delete current record, etc.

This functionality is currently only available in Android.

e.g.:

If you are working in Android and you want to use it, first you need to turn on the shake listener with the method TurnOnShake:

ShakeEventImg01

Then, you need to implement the code which will be executed in the event OnShake:

ShakeEventImg02

In this example, we are just counting how many times the user has shaked the device.

Finally, when you want to finish listening you need to use the method TurnOffShake:

ShakeEventImg03

OnShake

Deprecated

Event that is triggered when the phone is shaken.