Articles on: JavaScript Interface

JS: Launch Apps/Settings/Exit



Please note most functions apply to both Kiosk Browser and Launcher but some are specific the individual product.

Launch Apps/Settings/Exit JavaScript Functions

You can find the JavaScript test page at https://www.android-kiosk.com/jstest.htm Just set this as the Kiosk URL on your device to test the functions.

Open Settings

Opens Kiosk Browser Settings.

<script>
function openSettings()	{
Android.openSettings();
}
</script>
<a href="javascript:openSettings();">Open Settings</a>


Exit Kiosk Browser

Exits Kiosk Browser, you can specify whether a password is required.

<script>
function exitKiosk(requirepassword) {
Android.exitKiosk(requirepassword);
}
</script>
<a href="javascript:exitKiosk(true);">Exit Kiosk</a>
<a href="javascript:exitKiosk(false);">Exit Kiosk (no password)</a>


Restart Kiosk Browser

Restarts Kiosk Browser. Requires 2.0.34 or higher.

<script>
function restartApplication() {
Android.restartApplication();
}
</script>
<a href="javascript:restartApplication();">Restart Kiosk Browser</a>


Open WiFi Settings

Opens WiFi settings, you can specify whether a password is required. Requires version 1.45 or higher.

<script>
function openWIFISettings(requirepassword) {
Android.openWIFISettings(requirepassword);
}
</script>
<a href="javascript:openWIFISettings(true);">Open WiFi Settings</a>
<a href="javascript:openWIFISettings(false);">Open WiFi Settings (no password)</a>


Open WiFi Hotspot Settings

Opens WiFi hotspot settings. Requires version 2.6.4 (build 205) or higher.

<script>
function openWiFiHotspotSettings(requirepassword) {
Android.openWiFiHotspotSettings(requirepassword);
}
</script>
<a href="openWiFiHotspotSettings(true);">Open WiFi Hotspot Settings</a>


Open Application

Method 1. Opens application by specified package name, requires version 2.0.12 or higher.
Method 2. Opens application by specified package name, give Kiosk browser focus after specified interval (milliseconds). Requires version 2.0.22 or higher.

<script>
//OPEN APPLICATION
function openApplication(packagename) {
Android.openApplication(packagename);
}
//OPEN APPLICATION, GIVE KIOSK BROWSER FOCUS AFTER X INTERVAL
function openApplication(packagename, regainFocusInterval) {
Android.openApplication(packagename, regainFocusInterval);
}
</script>
<a href="javascript:openApplication('com.teamviewer.quicksupport.market');">Method 1. Open application</a>
<a href="javascript:openApplication('com.teamviewer.quicksupport.market', 5000);">Method 2. Open application, give Kiosk browser focus</a>


Open Application or Install

Open application if installed, if not display play store listing, requires version 2.6.6 or higher.

<script>
function openApplicationOrInstall(packagename) {
Android.openApplicationOrInstall(packagename);
}
</script>
<a href="javascript:openApplicationOrInstall('com.procoit.projectcamera');">Open application if installed, if not display play store listing</a><br/>


Open Camera Application

Opens default camera app, if more than one camera app is installed and default is not set, selection list will be shown, requires version 2.6.6 or higher.

<script>
function openCameraApplication() {
Android.openCameraApplication();
}
</script>
<a href="openCameraApplication();">Open Camera Application</a><br/>


Open File from Path

Opens file from specified path, requires version 2.6.6 or higher.

<script>
function openFile(path, mimetype) {
Android.openFile(path, mimetype)
}
</script>
<a href="javascript:openFile('/sdcard/kioskbrowser/localcontent/file.pdf','application/pdf');">Open File from path</a><br/>


Broadcast Intent

Method 1. Broadcast Intent, requires version 2.0.17 or higher.
Method 2. Broadcast Intent with extras, requires version 2.0.20 or higher.

<script>
//BROADCAST INTENT
function broadcastIntent(intent, allowForeground) {
Android.broadcastIntent(intent, allowForeground);
}
//BROADCAST INTENT WITH EXTRAS
function broadcastIntentExtras(intent, allowForeground) {
var extras = [["keyname1","value1"],["keyname2","value2"]];
Android.broadcastIntent(intent, allowForeground, extras.toString());
}
</script>
<a href="javascript:broadcastIntent('com.yourapp.YOUR_INTENT', false);">Method 1. Broadcast Intent</a>
<a href="javascript:broadcastIntentExtras('com.yourapp.YOUR_INTENT', false);">Method 2. Broadcast Intent (with extras)</a>


Start Service

Starts service with extras, requires version 2.0.31 or higher.

<script>
function startService(intent) {
var extras = [["keyname1","value1"]];
Android.startService(intent, extras.toString());
}
</script>
<a href="javascript:startService('com.procoit.projectcamera.PROCESS_UPLOADS');">Start Service (with extras)</a>


Start Activity with Intent

Starts activity (with extras if provided), requires version 2.0.38 (without extras) or 2.5.8 with extras.

<script>
function startActivityWithIntent(intent, allowForeground, packageName) {
Android.startActivityWithIntent(intent, allowForeground, packageName);
}
function startActivityWithIntentExtras(intent, allowForeground, packageName) {
var extras = [["keyname1","value1"]];
Android.startActivityWithIntent(intent, allowForeground, packageName, extras.toString());
}
</script>
<a href="javascript:startActivityWithIntent('com.esminis.server.STOP', true, 'com.esminis.server.php');">Start Activity (Sample stop Server for PHP seperate app)</a>
<a href="javascript:startActivityWithIntent('com.esminis.server.START', true, 'com.esminis.server.php');">Start Activity (Sample start Server for PHP seperate app)</a>​
<a href="javascript:startActivityWithIntentExtras('com.esminis.server.START', true, 'com.esminis.server.php');">Start Activity with extras (Sample start Server for PHP seperate app)</a>​


Start Activity by Class Name

Starts activity by class name, requires version 2.6.6 or higher.

<script>
function startActivityByClassName(fullclassname, allowForeground, packageName) {
	Android.startActivityByClassName(fullclassname, allowForeground, packageName);
}
</script>
​​<a href="javascript:startActivityByClassName('com.procoit.kioskbrowser.WakeUpActivity', true, 'com.procoit.kioskbrowser');">Start Activity by class name (Sample start Kiosk Wake Activity)</a>


Get Installed Applications

Returns array of installed applications, requires version 2.0.40 or higher.

<script>
function getInstalledApplications() {
var apps = Android.getInstalledApplications();
console.log(apps);
return apps;
}
</script>
<a href="javascript:alert(getInstalledApplications());">Get Installed Apps</a>

Updated on: 03/03/2021

Was this article helpful?

Share your feedback

Cancel

Thank you!