SureFox Javascript APIs

SureFox for Android now comes with built-in set of Javascript APIs. Use them in a customized SureFox toolbar or embed in your web application to perform variety of actions such as navigating through pages or to launch an app directly from SureFox.

The APIs are written as window.surefox.<API_Name>

Following is a comprehensive list of SureFox APIs:

  • getVersion(): Gets SureFox Version
  • getAndroidVersion(): Gets Device android version
  •  getDeviceModel(): Gets device model
  • forceIdleTimeout(): Forces idle timeout
  • autoMediaPlayEnabled(): Gets whether media playback enabled in surefox
  • isAppInstalled(“packageName”): Gets whether application with packagename is installed on device
  • setOrientation(integervalue): Sets orientation based on value 0-6 (0 -Auto,1-Landscape,2-Portrait,3-Reverse Landscape,4-Reverse Portrait,5 – Auto Landscape, 6-Auto Portrait)
  • getURL(): Gets url of current tab
  • exit(): Not applicable when SureFox is in Kiosk Mode
  • clearCache(): Clears surefox cache
  • clearOfflineData(): Clears offline data of surefox
  • setIdleTimeoutForCurrentPage(intergerValue): Sets idle timeout to specific value for current page
  • resetIdleTimeout(): Resets idle timeout
  • getIdleTimeout(): Gets current idle timeout time
  • launch(packageName,restartFlag): Launches specified application and restarts if restartFlag is true
  • hardWareAcceleration(intValue): Sets hardware acceleration to specified value 0- None,1-Software,2-Hardware
  • closeCurrentTab(): Closes currently opened tab
  • closeAlltabs(): Closes all opened tabs
  • load(URL): Loads the URL in the active screen of SureFox. URL is passed as a parameter to the API
  •  openInNewTab(URL): Loads the URL in a new tab of SureFox. URL is passed as a parameter to the API
  • back(): Navigate to the previous page in SureFox
  • forward(): Navigate to the next page in SureFox
  • home(): Loads SureFox home page
  • refresh(): Refreshes current web page
  • stop(): Stops any ongoing loading activity in SureFox
  • launch(packagename): Launches the application from SureFox. Only the package name of the application needs to be passed as a parameter to the API.
  • launch(action,category,packagename,classname): Use this to launch a particular activity of an application from SureFox. The action, category, package name and class name of the application need to be passed as parameters to the API.
window.surefox.launch('android.intent.action.MAIN', 'android.intent.category.LAUNCHER', '', '');

You can also use SureFox APIs to get and display battery status and perform actions based on the battery level. Following are the list of SureFox battery APIs:

  • battery().level(): Returns the current battery level
  • battery().charging(): Returns ‘true’ if battery is charging else returns a ‘false’
  • battery().addEventListener(“levelchange”, “<user-defined-function>”): Used to add an event listener for battery level which can be used to call any function of your choice
window.surefox.battery().addEventListener("levelchange", "setLevel");
  • battery().addEventListener(“chargingchange”, “<user-defined-function>“):
window.surefox.battery().addEventListener("chargingchange", "setStatus");
  •  getIMEI(): Returns the IMEI number of the phone device
  •  getWifiMAC(): Returns the WiFi MAC Address of the device


  •  getBluetoothMAC(): Returns the Bluetooth MAC Address of the device


  • getGUID(): Returns the GUID of the device


  •  launchFile(‘file_path’): Launches the file from SureFox. Complete file path needs to be passed as a parameter to the API.
Sample HTML page for displaying use of SureFox APIs:
SureFox Javascript API Demo page

SureFox Javascript API Demo page

HTML Code for demo page:

<title>SureFox Javascript APIs</title>
<script type=”text/javascript”>
function setLevel(value) {
document.querySelector(‘#level’).textContent = “Battery Level = ” + value*100+”%”;
function setStatus(value) {
document.querySelector(‘#status’).textContent = “Charging: ” + window.surefox.battery().charging();
function getdeviceInfo() {
document.querySelector(‘#IMEI’).textContent = “IMEI: ” + window.surefox.getIMEI();
document.querySelector(‘#WiFiMAC’).textContent = “WiFi MAC: ” + window.surefox.getWifiMAC();
document.querySelector(‘#BTMAC’).textContent = “Bluetooth MAC: ” + window.surefox.getBluetoothMAC();
document.querySelector(‘#GUID’).textContent = “GUID: ” + window.surefox.getGUID();
function init() {
window.surefox.battery().addEventListener(“levelchange”, “setLevel”);
window.surefox.battery().addEventListener(“chargingchange”, “setStatus”);
margin: 0px;
padding: 5px 15px;
background-color: #87D2FF;
border-radius: 5px;
color: #ffffff;
font-weight: bold;
text-shadow: 0 0 1px #525252;

<body onload=”javascript:init()”>

<div id=”container” style=”background-color: #cccccc; height: 62px; position:relative;”>
<div style=”float:right; margin: 5px 5px 0px 0px; background-color: rgba(255, 255, 255, 0.62); padding: 5px 10px; height: 68%; “>
<!–<b><u>Real Time Battery Status:</u></b>–>
<div id=”status” style=”background-image: url(./charging.png); background-repeat: no-repeat; margin: 0 0 0 -6px; padding: 0 0 0 40px; background-position: left; display: inline-block;”>(charging state unknown)</div>
<div id=”level” style=”background-image: url(./battery.png); background-repeat: no-repeat; margin: 0 0 0 -6px; padding: 0 0 0 40px; background-position: left; display: block;”>(battery level unknown)</div>
<div style=”position:absolute; top:20%; left:0; width:100%;”>
<span onclick=”window.surefox.home();”>
<button class=”bar”>Home</button>
<span onclick=”window.surefox.back();”>
<button class=”bar”>Back</button>
<span onclick=”window.surefox.forward();”>
<button class=”bar”>Forward</button>
<span onclick=”window.surefox.refresh();”>
<button class=”bar”>Refresh</button>
<span onclick=”window.surefox.stop();”>
<button class=”bar”>Stop</button>
<span onclick=”window.surefox.launch(‘’);”>
<button class=”bar”>Calendar</button>
<span onclick=”window.surefox.launch(‘android.intent.action.MAIN’, ‘android.intent.category.LAUNCHER’, ‘’, ‘’);”>
<button class=”bar”>Google Play</button>
<br />
<span onclick=”window.surefox.load(‘’);”>Click to visit 42Gears</span>
<br />
<br />
<span onclick=”window.surefox.openInNewTab(‘’);”>Click to launch Google(Open in new tab)</span>
<br />
<br />
<span onclick=”window.surefox.launchFile(‘/mnt/sdcard/SureFox.settings’);”>Click to launch document</span>
<br />
<br />
<div id=”IMEI” style=”margin: 0 0 0 0px; padding: 0 0 0 0px; background-position: left; display: block;”>(IMEI unknown)</div>
<div id=”WiFiMAC” style=”margin: 0 0 0 0px; padding: 0 0 0 0px; background-position: left; display: block;”>(WiFi MAC address unknown)</div>
<div id=”BTMAC” style=”margin: 0 0 0 0px; padding: 0 0 0 0px; background-position: left; display: block;”>(Bluetooth MAC address unknown)</div>
<div id=”GUID” style=”margin: 0 0 0 0px; padding: 0 0 0 0px; background-position: left; display: block;”>(GUID unknown)</div>


To know more about SureFox, click here

To learn more on how to secure and manage Android, iOS and Windows Mobile/CE devices efficiently, visit us at


  1. Serge Blais on Tuesday April 23rd, 2013 at 09:19 PM

    Thanks for adding the new API calls 😉

  2. Serge Blais on Tuesday March 26th, 2013 at 11:28 PM

    This API would be more complete if the surefox GUID was exposed as well.
    window.surefox.guid() returns the guid generated uppon installation of Surefox.

Leave a Comment