The System API is used to control and modify core aspects of the device such as the screen, OS and device capabilities.
This API is part of the coreapi
extension that is included automatically.
extensions: ["coreapi"]
Be sure to review the JavaScript API Usage guide for important information about using this API in JavaScript.
Be sure to review the Ruby API Usage guide for important information about using this API in Ruby.
Install an application.
Parameters
The url of an application to install on the device.
Synchronous Return:
Method Access:
Rho.System.applicationInstall(STRING applicationUrl)
Rho::System.applicationInstall(STRING applicationUrl)
Uninstall the application. Not Supported on Windows CE devices.
Parameters
The name of the application.
Synchronous Return:
Method Access:
Rho.System.applicationUninstall(STRING applicationName)
Rho::System.applicationUninstall(STRING applicationName)
Bring application window to the top of the screen.
Synchronous Return:
Method Access:
Rho.System.bringToFront()
Rho::System.bringToFront()
Use Network.clearStatusNotify: Clear network status callback.
Synchronous Return:
Method Access:
Rho.System.clearNetworkStatusNotify()
Rho::System.clearNetworkStatusNotify()
Delete folder.
Parameters
Path to folder.
Synchronous Return:
Method Access:
Rho.System.deleteFolder(STRING pathToFolder)
Rho::System.deleteFolder(STRING pathToFolder)
Deletes the specified value from the device registry. Only applicable on Windows Mobile / Embedded Handheld and CE devices. When running on RhoSimulator, this method is supported only for Windows OS.
Parameters
Map of properties associated with the registry key being set.
The hive name, setRegistrySetting.
Full path of the key, including ‘\’ separators as required. Remember to use ‘\’ in JavaScript to specify backslash.
The name of the setting to be deleted.
If the registry value was set to be persistent, ie a corresponding .reg file was created in the \Application folder then setting true here will delete that .reg file.
Synchronous Return:
Whether or not the registry key was successfully deleted.
Method Access:
Rho.System.deleteRegistrySetting(HASH propertyMap)
Rho::System.deleteRegistrySetting(HASH propertyMap)
Use Application.quit: exit application.
Synchronous Return:
Method Access:
Rho.System.exit()
Rho::System.exit()
This method will return all of object/value pairs for the propertyNames of the API class.
Parameters
Async Callback Returning Parameters: HASH
Synchronous Return:
Map of all available properties
: this method also supports async callbacks - check the Callback tab for callback return parameters.
Method Access:
Rho.System.getAllProperties(CallBackHandler callback)
Rho::System.getAllProperties(CallBackHandler callback)
This method will return a set of object/value pairs for the list of the propertyName that is passed in. The propertyNames must be a valid property of the API class.
Parameters
List of properties I want to know about
Async Callback Returning Parameters: HASH
Synchronous Return:
Map of properties I want to know about
: this method also supports async callbacks - check the Callback tab for callback return parameters.
Method Access:
Rho.System.getProperties(ARRAY arrayofNames, CallBackHandler callback)
Rho::System.getProperties(ARRAY arrayofNames, CallBackHandler callback)
This method will return the value of the propertyName that is passed in. The propertyName must be a valid property of the API class.
Parameters
The property to return info about.
Async Callback Returning Parameters: STRING
Synchronous Return:
The property to return info about.
: this method also supports async callbacks - check the Callback tab for callback return parameters.Method Access:
Rho.System.getProperty(STRING propertyName, CallBackHandler callback)
Rho::System.getProperty(STRING propertyName, CallBackHandler callback)
Retrieve a value from the device registry. Only applicable on Windows Mobile / Embedded Handheld and CE devices. When running on RhoSimulator, this method is supported only for Windows OS.
Parameters
Map of properties associated with the registry key being set.
The hive name, see setRegistrySetting.
Full path of the key, including ‘\’ separators as required. Remember to use ‘\’ in JavaScript to specify backslash.
The name of the setting to be retrieved.
Synchronous Return:
Registry value of the key.
Method Access:
Rho.System.getRegistrySetting(HASH propertyMap)
Rho::System.getRegistrySetting(HASH propertyMap)
Return the command line parameters. At Android start parameters are returned as URL query string starting with ‘?’, name-value delimiter ‘=’ and name value pairs delimiter ‘&’.
Synchronous Return:
Method Access:
Rho.System.getStartParams()
Rho::System.getStartParams()
Use System.locale property: Current device locale.
Synchronous Return:
Method Access:
Rho.System.get_locale()
Rho::System.get_locale()
Checks if the specified applicationName is installed on the device.
Parameters
The name of the application.
Synchronous Return:
Method Access:
Rho.System.isApplicationInstalled(STRING applicationName)
Rho::System.isApplicationInstalled(STRING applicationName)
Use Database.SQLite3.isBlobAttr: is model attribute is blob.
Parameters
Synchronous Return:
Method Access:
Rho.System.isBlobAttr(STRING partition, INTEGER sourceID, STRING attrName)
Rho::System.isBlobAttr(STRING partition, INTEGER sourceID, STRING attrName)
Open the application associated with the URL. Behavior may be different on different platforms and depend on installed software. For example, open URL with http:// prefix will execute the Web Browser installed on system and open URL in executed browser. Note: For opening pdf files on android devices it is necessary to add option “no_compression: [ pdf ]” to android section in build.yml
Parameters
URL as string.
Synchronous Return:
Method Access:
Rho.System.openUrl(STRING url)
Rho::System.openUrl(STRING url)
Replace application bundle.
Parameters
Local path to bundle folder. See Build Application/Upgrade Application section to find out how to build bundle on computer.
Update parameters.
If true, when Application will not be automatically restarted after the replace bundle is finished.
Synchronous Return:
Method Access:
Rho.System.replaceCurrentBundle(STRING pathToBundle, HASH params)
Rho::System.replaceCurrentBundle(STRING pathToBundle, HASH params)
Run an application.
Parameters
The name of the application on the device to run. It depends from platform. On iOS it is BundleURLScheme of executed application.
Start parameters string. Executed Application can receive this string by getStartParams method. Parameter could be just value, or key-value pair separated by ‘=’ sign. Please note that for each platform there are distinct ways to write several params at once. On Android parameters should be separated by “&”, on other platforms by ‘,’ or ‘ ’.
Not Implemented.
False by default.
Synchronous Return:
Method Access:
Rho.System.runApplication(STRING appName, STRING params, BOOLEAN blockingCall)
Rho::System.runApplication(STRING appName, STRING params, BOOLEAN blockingCall)
Set do not backup attribute for file.
Parameters
Path to file.
True set doNotBackup attribute to file (exclude this file from backup), false for remove doNotBackup attribute from file.
Synchronous Return:
Method Access:
Rho.System.setDoNotBackupAttribute(STRING pathToFile, BOOLEAN doNotBackup)
Rho::System.setDoNotBackupAttribute(STRING pathToFile, BOOLEAN doNotBackup)
Use Network.setStatusNotify: set network notification callback.
Parameters
The url to the user-defined callback method.
IOS. The network status polling period for systems that can not notify network status change immediately. Default value is 20 seconds.
Synchronous Return:
Method Access:
Rho.System.setNetworkStatusNotify(STRING url, INTEGER poll_interval)
Rho::System.setNetworkStatusNotify(STRING url, INTEGER poll_interval)
This method will set the values of a list of properties for the API class. The propertyName must be a valid property for the class and must also not be read only.
Parameters
Map of properties I want to set
Synchronous Return:
Method Access:
Rho.System.setProperties(HASH propertyMap)
Rho::System.setProperties(HASH propertyMap)
This method will set the value of a property for the API class. The propertyName must be a valid property for the class and must also not be read only.
Parameters
The one property name that I want to set
The one property value that I want to set
Synchronous Return:
Method Access:
Rho.System.setProperty(STRING propertyName, STRING propertyValue)
Rho::System.setProperty(STRING propertyName, STRING propertyValue)
Use Push.setPushNotification: Register push callback, the method to call upon receiving a push message.
Parameters
URL of the callback method. If empty, unregisters rhoconnect-push.
Parameters which will be added to callback URL.
Name of a push service client. Current values can be ‘rhoconnect_push’ or ‘gcm’ or ‘legacy’ or empty.
The call will be applied to every push client.
Synchronous Return:
Method Access:
Rho.System.setPushNotification(STRING url, STRING url_params, STRING push_client)
Rho::System.setPushNotification(STRING url, STRING url_params, STRING push_client)
Set a value in the device registry. Only applicable on Windows Mobile / Embedded Handheld and CE devices. When running on RhoSimulator, this method is supported only for Windows OS.
Parameters
Map of properties associated with the registry key being set.
The hive name.
Possible Values :
Set the property in the HKEY_CLASSES_ROOT hive.
Set the property in the HKEY_CURRENT_USER hive.
Set the property in the HKEY_LOCAL_MACHINE hive.
Set the property in the HKEY_USERS hive.
The type.
Possible Values :
The type of the value being set is a string.
The type of the value being set is a binary number.
The type of the value being set is a natural number (DWORD)
The type of the value being set is a multi line string. Separate your lines with \n (\n in JavaScript)
Full path of the key, including ‘\’ separators as required. Remember to use ‘\’ in JavaScript to specify backslash.
The name of the registry setting to be set.
The registry value to be set.
Whether or not to create a corresponding merge file, setting to true will cause your value to persist across a device clean boot. A .reg file is written to the \Application folder on the device to persist the setting.
Synchronous Return:
Whether or not the registry key was successfully set.
Method Access:
Rho.System.setRegistrySetting(HASH propertyMap)
Rho::System.setRegistrySetting(HASH propertyMap)
Use ScreenOrientation.setScreenOrientationEvent: Notify (call a callback method) when the screen rotates.
Parameters
URL of the callback method. If empty, unregisters notification callback.
Parameters which will be added to callback URL.
Synchronous Return:
Method Access:
Rho.System.setScreenRotationNotification(STRING url, STRING url_params)
Rho::System.setScreenRotationNotification(STRING url, STRING url_params)
Change application window position and size.
Parameters
Left corner of window.
Top corner of window.
Width of window.
Height of window.
Synchronous Return:
Method Access:
Rho.System.setWindowFrame(INTEGER x, INTEGER y, INTEGER width, INTEGER height)
Rho::System.setWindowFrame(INTEGER x, INTEGER y, INTEGER width, INTEGER height)
Change application window position.
Parameters
Left corner of window.
Top corner of window.
Synchronous Return:
Method Access:
Rho.System.setWindowPosition(INTEGER x, INTEGER y)
Rho::System.setWindowPosition(INTEGER x, INTEGER y)
Change application window size.
Parameters
Width of the window.
Width of the of window.
Synchronous Return:
Method Access:
Rho.System.setWindowSize(INTEGER width, INTEGER height)
Rho::System.setWindowSize(INTEGER width, INTEGER height)
Use System.applicationIconBadge: Set the application icon to have this badge number. Set to 0 (zero) to remove badge.iOS only.
Parameters
Synchronous Return:
Method Access:
Rho.System.set_application_icon_badge(INTEGER badgeNumber)
Rho::System.set_application_icon_badge(INTEGER badgeNumber)
Use System.httpProxyURI property: To use client with the HTTP proxy.
Parameters
Synchronous Return:
Method Access:
Rho.System.set_http_proxy_url(STRING proxyURI)
Rho::System.set_http_proxy_url(STRING proxyURI)
Use Application.setLocale method: set application specific locale.
Parameters
Synchronous Return:
Method Access:
Rho.System.set_locale(STRING locale_code, STRING country_code)
Rho::System.set_locale(STRING locale_code, STRING country_code)
Use System.screenSleeping property: enable / disable phone sleeping.
Parameters
Synchronous Return:
Method Access:
Rho.System.set_sleeping(BOOLEAN enable)
Rho::System.set_sleeping(BOOLEAN enable)
Use Timer.start: start timer.
Parameters
Timer interval.
URL of the callback method.
Parameters which will be added to callback URL.
Synchronous Return:
Method Access:
Rho.System.startTimer(INTEGER interval, STRING url, STRING url_params)
Rho::System.startTimer(INTEGER interval, STRING url, STRING url_params)
Use Timer.stop: stop timer.
Parameters
URL of the callback method which identify the timer to stop.
Synchronous Return:
Method Access:
Rho.System.stopTimer(STRING url)
Rho::System.stopTimer(STRING url)
Use System.httpProxyURI property: Stop using HTTP proxy that was set by the command line, rhoconfig.txt or set_http_proxy_url.
Synchronous Return:
Method Access:
Rho.System.unset_http_proxy()
Rho::System.unset_http_proxy()
Unzip file.
Parameters
The path to the file to be unzipped. Application should have write permissions to this folder.
Password for the zip.
Synchronous Return:
Method Access:
Rho.System.unzipFile(STRING localPathToZip, STRING password)
Rho::System.unzipFile(STRING localPathToZip, STRING password)
Use Database.updateBlobAttribs: update model blob attributes list.
Parameters
Synchronous Return:
Method Access:
Rho.System.updateBlobAttribs(STRING partition, INTEGER sourceID)
Rho::System.updateBlobAttribs(STRING partition, INTEGER sourceID)
Zip one file. Zip archive must placed to the folder where application can write files.
Parameters
The path to the specified zip. Application should have write permissions to this folder.
The path to the file to be zipped.
Password for the zip.
Synchronous Return:
Method Access:
Rho.System.zipFile(STRING localPathToZip, STRING localPathToFile, STRING password)
Rho::System.zipFile(STRING localPathToZip, STRING localPathToFile, STRING password)
Zip list of files.
Parameters
The path to the specified zip.
Base path to the files to be zipped.
List of file paths to be zipped.
Password for the zip.
Synchronous Return:
Method Access:
Rho.System.zipFiles(STRING localPathToZip, STRING basePath, ARRAY filePathsToZip, STRING password)
Rho::System.zipFiles(STRING localPathToZip, STRING basePath, ARRAY filePathsToZip, STRING password)
Set the application icon to have this badge number. Set to 0 (zero) to remove badge.
Property Access:
Rho.System.applicationIconBadge
Rho::System.applicationIconBadge
Current device country code.
Property Access:
Rho.System.country
Rho::System.country
Name of device application running on. Examples: ‘9000’ (BB), ‘iPhone’, ‘dream’ (Android).
Property Access:
Rho.System.deviceName
Rho::System.deviceName
Primary email of phone owner. To access this property ‘pim’ capability must be enabled in your build.yml.
Property Access:
Rho.System.deviceOwnerEmail
Rho::System.deviceOwnerEmail
Name(account name) of phone owner. To access this property ‘pim’ capability must be enabled in your build.yml.
Property Access:
Rho.System.deviceOwnerName
Rho::System.deviceOwnerName
Push notifications device ID which may be used to receive push messages.To get this ID , Push service should be configured on the device. Please refer to Push documentation.
Property Access:
Rho.System.devicePushId
Rho::System.devicePushId
Get free local server port, available for binding.
Property Access:
Rho.System.freeServerPort
Rho::System.freeServerPort
Returns true if calendar support is available.
Property Access:
Rho.System.hasCalendar
Rho::System.hasCalendar
Returns true if there is a camera available on the device.
Property Access:
Rho.System.hasCamera
Rho::System.hasCamera
Use Network.hasCellNetwork to tell if device is connected to the cell network.
Property Access:
Rho.System.hasCellNetwork
Rho::System.hasCellNetwork
Use Network.hasNetwork to tell if the device is connected to the network.
Property Access:
Rho.System.hasNetwork
Rho::System.hasNetwork
Returns true if the device has sqlite capabilities (previously only BlackBerry did not support this).
Property Access:
Rho.System.hasSqlite
Rho::System.hasSqlite
Returns true if the device has touch screen capabilities.
Property Access:
Rho.System.hasTouchscreen
Rho::System.hasTouchscreen
Use Network.hasWifiNetwork to tell if the device is connected to the wifi network.
Property Access:
Rho.System.hasWifiNetwork
Rho::System.hasWifiNetwork
Set HTTP proxy parameters for using by Network module. Example: user:password@url:port . Support only basic authentication. Setting the property overrides http_proxy_uri, http_proxy_port, http_proxy_user, http_proxy_password in rhoconfig.txt. To set proxy for Zebra WebKit for Windows Mobile/CE use config.xml settings.
Property Access:
Rho.System.httpProxyURI
Rho::System.httpProxyURI
Returns true if the application is running on a platform emulator.
Property Access:
Rho.System.isEmulator
Rho::System.isEmulator
Returns true if the device supports Zebra device capabilities. APIs will indicate if the property or method is available on MSI devices only. You can use this property to help your application decide when to take advantage of advanced MSI capabilities.
Property Access:
Rho.System.isMotorolaDevice
Rho::System.isMotorolaDevice
Returns true if the application is running on RhoSimulator.
Property Access:
Rho.System.isRhoSimulator
Rho::System.isRhoSimulator
For Windows Mobile and Windows CE the keyboard can be manually shown or hidden as required. All other platforms only support ‘automatic’. The default state for Windows Mobile and Windows CE is manual, for all other platforms it is automatic.
Default: See Description
Possible Values (STRING):
Shows the on screen keyboard, after setting the keyboard to shown or hidden it will no longer appear / disappear automatically until you set this property to automatic.
Hides the on screen keyboard, after setting the keyboard to shown or hidden it will no longer appear / disappear automatically until you set this property to automatic. This is most useful if your device has a hardware keyboard or you are scanning / capturing data to an input field.
Automatically shows or hides the keyboard as needed by the application.
Property Access:
Rho.System.keyboardState
Rho::System.keyboardState
Port of the local (embedded) HTTP server. This parameter is mainly for debug purposes. If not specified, the platform will detect a free port on the device and use that one.
Default: 8080
Property Access:
Rho.System.localServerPort
Rho::System.localServerPort
Current device locale Like ‘en’, ‘ru’ etc.
Property Access:
Rho.System.locale
Rho::System.locale
Lock / unlock the window size change by the user. When running on RhoSimulator, this method is supported only for Windows OS.
Default: false
Property Access:
Rho.System.lockWindowSize
Rho::System.lockWindowSize
The OEM Information string for the terminal.
Property Access:
Rho.System.oemInfo
Rho::System.oemInfo
Version OS of device. Examples: ‘4.6.0.192’ (BB), ‘3.0’ (iPhone), ‘1.6’ (Android).
Property Access:
Rho.System.osVersion
Rho::System.osVersion
Hardware based ID. It depends on capabilities configured for an application and has to remain same even across application uninstall/install.
Property Access:
Rho.System.phoneId
Rho::System.phoneId
Platform where application is running.
Possible Values (STRING):
Property Access:
Rho.System.platform
Rho::System.platform
Horizontal PPI (Pixels Per Inch).
Property Access:
Rho.System.ppiX
Rho::System.ppiX
Vertical PPI (Pixels Per Inch).
Property Access:
Rho.System.ppiY
Rho::System.ppiY
Screen height in real pixels.
Property Access:
Rho.System.realScreenHeight
Rho::System.realScreenHeight
Screen width in real pixels.
Property Access:
Rho.System.realScreenWidth
Rho::System.realScreenWidth
Screen auto rotate.
Default: true
Property Access:
Rho.System.screenAutoRotate
Rho::System.screenAutoRotate
Screen height in logical pixels (used for set coordinates).
Property Access:
Rho.System.screenHeight
Rho::System.screenHeight
Current screen orientation.
Possible Values (STRING):
The return value if the screen is in portrait mode.
The return value if the screen is in landscape mode.
Property Access:
Rho.System.screenOrientation
Rho::System.screenOrientation
If true, then screen will go to sleep by system inactivity timeout. If false then screen never go to sleep while application is in foreground.
Property Access:
Rho.System.screenSleeping
Rho::System.screenSleeping
Screen width in logical pixels (used for set coordinates).
Property Access:
Rho.System.screenWidth
Rho::System.screenWidth
The Unique Unit IDentifier for the terminal.
Property Access:
Rho.System.uuid
Rho::System.uuid
Browser framework identity string.
Property Access:
Rho.System.webviewFramework
Rho::System.webviewFramework
You can find out whether the device has access to several system-dependent features such as calendar, camera, touchscreen, etc.
// Returns true if device supports Zebra device capabilities, such as Scanner, etc. var is_motorola_device = Rho.System.isMotorolaDevice; var has_calendar = Rho.System.hasCalendar; var has_camera = Rho.System.hasCamera; var has_cell_network = Rho.System.hasCellNetwork; var has_wifi_network = Rho.System.hasWifiNetwork; var has_network = Rho.System.hasNetwork; var has_sqlite = Rho.System.hasSqlite; var has_touchscreen = Rho.System.hasTouchscreen; message = "Zebra device: "+is_motorola_device+"\n"+ "Calendar: "+has_calendar+"\n"+ "Camera: "+has_camera+"\n"+ "Cell network: "+has_cell_network+"\n"+ "WiFi: "+has_wifi_network+"\n"+ "Network: "+has_network+"\n"+ "SQLite: "+has_sqlite+"\n"+ "Touchscreen: "+has_touchscreen; alert(message);
# Returns true if device supports Zebra device capabilities, such as barcode scanner, etc. is_motorola_device = Rho::System.isMotorolaDevice has_calendar = Rho::System.hasCalendar has_camera = Rho::System.hasCamera has_cell_network = Rho::System.hasCellNetwork has_wifi_network = Rho::System.hasWifiNetwork has_network = Rho::System.hasNetwork has_sqlite = Rho::System.hasSqlite has_touchscreen = Rho::System.hasTouchscreen message = " Zebra device: #{is_motorola_device} Calendar: #{has_calendar} Camera: #{has_camera} Cell network: #{has_cell_network} WiFi: #{has_wifi_network} Network: #{has_network} SQLite: #{has_sqlite} Touchscreen: #{has_touchscreen} " Alert.show_popup(message)
Retrieve the version of the underlying Operating System.
var version_info = Rho.System.osVersion;
alert(version_info);
version_info = Rho::System.osVersion Alert.show_popup(version_info)
You can ask the system to install or uninstall a different application. This feature is useful for installing sub-applications, custom upgrades, etc.
// install an application from given url Rho.System.applicationInstall("/bin/target/android/rhodes-app-debug.apk"); // uninstall the application Rho.System.applicationUninstall("rhodes-app");
#install an application from given url Rho::System.applicationInstall("/bin/target/android/rhodes-app-debug.apk") # uninstall the application Rho::System.applicationUninstall("rhodes-app")
If necessary, you can read the embedded HTTP server’s port, for debugging purposes.
// Get port of the local (embedded) HTTP server var local_port = Rho.System.localServerPort; alert(local_port);
# Get port of the local (embedded) HTTP served local_port = Rho::System.localServerPort() Alert.show_popup(local_port)
If you ever need to build or extract zip archives, RhoMobile includes easy-to-use APIs for this task.
// unzip file Rho.System.unzipFile("/app/public/sample.zip"); // zip file Rho.System.zipFile("/app/public/zipfile.zip", "/app/public/sample.txt");
# unzip a file Rho::System.unzipFile("/app/public/sample.zip") # zip a file Rho::System.zipFile("/app/public", "/app/public/sample.txt")
On devices running Windows Mobile, Windows CE, Windows Embedded Handheld and Windows Embedded CE it is possible to interact with the registry, this example shows how to do that.
#/app/Model # Retrieve a value from the Registry def get_registry_sync theRegSetting = Rho::System.getRegistrySetting({hive:'HKLM', key:'software', Setting:'RhoElementsTest'}) puts "Registry Setting retrieved: #{theRegSetting}" end # Set a value in the registry which will persist across a clean boot of the device def set_registry_sync theRegSetting = Rho::System.setRegistrySetting({hive:'HKLM', type:'String', key:'Software', setting:'RhoElementsTest', value:'MVC ftw', persistent:true}) puts "Registry Setting Success?: #{theRegSetting}" end # Delete a value from the registry def delete_registry_sync theRegSetting = Rho::System.deleteRegistrySetting({hive:'HKLM', key:'Software', setting:'RhoElementsTest', persistent:true}) puts "Registry Deleting Success?: #{theRegSetting}" end