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()
Gathers system dependent information ( hw info, installed packages etc ). Return key/value pairs depend on platform.
Synchronous Return:
Method Access:
Rho.System.getSystemInfo()
Rho::System.getSystemInfo()
Use System.locale property: Current device locale.
Synchronous Return:
Method Access:
Rho.System.get_locale()
Rho::System.get_locale()
Hide Splash Screen if delay is configured as -1 in rhoconfig.txt
Synchronous Return:
Method Access:
Rho.System.hideSplashScreen()
Rho::System.hideSplashScreen()
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. In android, “sms:”,“mailto:”,“tel:”,“http:”,“https:”,“file:” are supported. For file url the proper permission and path has to be given. For external storage space fully qualified path has to be given.(Example:-file:///storage/sdcard/sample.jpg). Hence only external storage space and userFolder are supported for file uri in android.
Parameters
URL as string.
Synchronous Return:
Method Access:
Rho.System.openUrl(STRING url)
Rho::System.openUrl(STRING url)
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 an amperstand, on other platforms by a comma or a space.
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)
Start timer. (It’s works only with Ruby)
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)
Stop timer. (It’s works only with Ruby)
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.
Output file name. Used when decompressing gzip streams.
Synchronous Return:
Method Access:
Rho.System.unzipFile(STRING localPathToZip, STRING password, STRING outputFileName)
Rho::System.unzipFile(STRING localPathToZip, STRING password, STRING outputFileName)
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)
Port of the local (embedded) Node.js HTTP server if it started (only for Node.js type applications).
Default: 3000
Property Access:
myObject.NodejsServerPort
Set the application icon to have this badge number. Set to 0 (zero) to remove badge.
Property Access:
myObject.applicationIconBadge
Current device country code.
Property Access:
myObject.country
Name of device application running on. Examples: ‘9000’ (BB), ‘iPhone’, ‘dream’ (Android). In Consumer Android device, name of the Industrial Design along with manufacturer name shall be shown.
Property Access:
myObject.deviceName
Primary email of phone owner. To access this property ‘pim’ capability must be enabled in your build.yml.
Property Access:
myObject.deviceOwnerEmail
Name(account name) of phone owner. To access this property ‘pim’ capability must be enabled in your build.yml.
Property Access:
myObject.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:
myObject.devicePushId
Return the primary shared/external storage directory. This directory may not currently be accessible if it has been mounted by the user on their computer, has been removed from the device, or some other problem has happened.
Property Access:
myObject.externalStorageDirectoryPath
Get free local server port, available for binding.
Property Access:
myObject.freeServerPort
Returns true if calendar support is available.
Property Access:
myObject.hasCalendar
Returns true if there is a camera available on the device.
Property Access:
myObject.hasCamera
Use Network.hasCellNetwork to tell if device is connected to the cell network.
Property Access:
myObject.hasCellNetwork
Use Network.hasNetwork to tell if the device is connected to the network.
Property Access:
myObject.hasNetwork
Returns true if the device has sqlite capabilities (previously only BlackBerry did not support this).
Property Access:
myObject.hasSqlite
Returns true if the device has touch screen capabilities. For Win32 desktop builds this API will return whether mouse support is available.
Property Access:
myObject.hasTouchscreen
Use Network.hasWifiNetwork to tell if the device is connected to the wifi network.
Property Access:
myObject.hasWifiNetwork
Set HTTP proxy parameters for using the Network module. Example: ‘user:password@url:port’. Supports basic authentication only. Do not include ‘http://’. Setting this property overrides http_proxy_uri, http_proxy_host, http_proxy_port, http_proxy_user and http_proxy_password. Proxy settings for Windows Mobile/CE with Zebra WebKit should be configured in the config.xml file.
Property Access:
myObject.httpProxyURI
Returns true if the application is running on a platform emulator.
Property Access:
myObject.isEmulator
Returns true if the application is running on RhoSimulator.
Property Access:
myObject.isRhoSimulator
Returns true if the device supports Symbol device capabilities. APIs will indicate if the property or method is available on Symbol devices only. You can use this property to help your application decide when to take advantage of advanced Symbol capabilities.
Property Access:
myObject.isSymbolDevice
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:
myObject.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:
myObject.localServerPort
Current device locale Like ‘en’, ‘ru’ etc.
Property Access:
myObject.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:
myObject.lockWindowSize
The OEM Information string for the terminal.
Property Access:
myObject.oemInfo
Version OS of device. Examples: ‘4.1’ (Android).
Property Access:
myObject.osVersion
Hardware based ID. It depends on capabilities configured for an application and has to remain same even across application uninstall/install.(except iOS ! – on iOS unisntall/reinstall will update this property – used UIDebice.identifierForVendor)
Property Access:
myObject.phoneId
Platform where application is running.
Possible Values (STRING):
Property Access:
myObject.platform
Horizontal PPI (Pixels Per Inch).
Property Access:
myObject.ppiX
Vertical PPI (Pixels Per Inch).
Property Access:
myObject.ppiY
Screen height in real pixels.
Property Access:
myObject.realScreenHeight
Screen width in real pixels.
Property Access:
myObject.realScreenWidth
Screen auto rotate.
Default: true
Property Access:
myObject.screenAutoRotate
Screen height in logical pixels (used for set coordinates).
Property Access:
myObject.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:
myObject.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:
myObject.screenSleeping
Screen width in logical pixels (used for set coordinates).
Property Access:
myObject.screenWidth
The Unique Unit IDentifier for the terminal.
Property Access:
myObject.uuid
Browser framework identity string.
Property Access:
myObject.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 Symbol device capabilities, such as Scanner, etc. var is_symbol_device = Rho.System.isSymbolDevice; 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 = "Symbol device: "+is_symbol_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 Symbol device capabilities, such as barcode scanner, etc. is_symbol_device = Rho::System.isSymbolDevice 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 = " Symbol device: #{is_symbol_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