JS: Hardware
Hardware JavaScript Functions
Please note most functions apply to both Kiosk Browser and Launcher but some are specific the individual product.
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.
Enables or disables WiFi, requires version 1.43 or higher.
Enables or disables WiFi Hotspot, requires version 2.6.4 (build 205) or higher.
Vibrates for the specified number of milliseconds.
Gets state of screen, requires version 2.6.6 (build 228) or higher.
Turns screen off, requires version 2.0.12 or higher.
Turns screen on, requires version 2.6.6 or higher.
Sets screen orientation, requires version 2.0.36 or higher.
Returns screen brightness (range of 1 - 255), requires version 2.0.16 or higher.
Sets screen brightness (range of 1 - 255), requires version 1.43 or higher.
Returns volume level of specified type, requires version 2.0.38 or higher.
Returns maximum volume level of specified type, requires version 2.0.38 or higher.
Sets volume level of specified type, requires version 2.0.38 or higher.
Returns WiFi signal strength (range of 0-4), requires version 2.5.6 or higher.
Returns Cell signal strength (range of 0-4), requires version 2.5.6 or higher + Android 4.2 or higher.
Returns Cell network type i.e. HSDPA, LTE etc... Requires version 2.5.6 or higher + Android 4.2 or higher.
Enables or disables Bluetooth, requires version 2.5.7 or higher.
Please note most functions apply to both Kiosk Browser and Launcher but some are specific the individual product.
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.
Enable/Disable WiFi
Enables or disables WiFi, requires version 1.43 or higher.
<script>
//TOGGLE WIFI
function setWiFiEnabled(enabled) {
Android.setWiFiEnabled(enabled);
}
</script>
<a href="javascript:setWiFiEnabled(false);">Disable WiFi</a>
<a href="javascript:setWiFiEnabled(true);">Enable WiFi</a>
Enable/Disable WiFi Hotspot
Enables or disables WiFi Hotspot, requires version 2.6.4 (build 205) or higher.
<script>
//TOGGLE WIFI
function setWiFiHotspotEnabled(enabled) {
Android.setWiFiHotspotEnabled(enabled);
}
</script>
<a href="javascript:setWiFiHotspotEnabled(false);">Disable WiFi Hotspot</a>
<a href="javascript:setWiFiHotspotEnabled(true);">Enable WiFi Hotspot</a>
Vibrate
Vibrates for the specified number of milliseconds.
<script>
function vibrate(milliseconds) {
Android.vibrate(milliseconds);
}
</script>
<a href="javascript:vibrate(1000);">Vibrate</a>
Get Screen State (is screen on)
Gets state of screen, requires version 2.6.6 (build 228) or higher.
<script>
function isScreenOn() {
return Android.isScreenOn();
}
</script>
<a href="javascript:showAndroidToast(isScreenOn());">Is Screen On?</a>
Turn Screen Off
Turns screen off, requires version 2.0.12 or higher.
<script>
function turnScreenOff() {
Android.turnScreenOff();
}
</script>
<a href="javascript:turnScreenOff();">Turn Screen Off</a>
Turn Screen On
Turns screen on, requires version 2.6.6 or higher.
<script>
function turnScreenOn() {
Android.turnScreenOn();
}
</script>
<a href="javascript:turnScreenOn();">Turn Screen On</a>
Set Screen Orientation
Sets screen orientation, requires version 2.0.36 or higher.
<script>
var SCREEN_ORIENTATION_LANDSCAPE = 1;
var SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 2;
var SCREEN_ORIENTATION_PORTRAIT = 3;
var SCREEN_ORIENTATION_REVERSE_PORTRAIT = 4;
var SCREEN_ORIENTATION_SENSOR = 5;
function setScreenOrientation(orientation) {
Android.setScreenOrientation(orientation);
}
</script>
<a href="javascript:setScreenOrientation(SCREEN_ORIENTATION_LANDSCAPE);">Set Screen Orientation (Landscape)</a>
<a href="javascript:setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT);">Set Screen Orientation (Portrait)</a>
Get Screen Brightness
Returns screen brightness (range of 1 - 255), requires version 2.0.16 or higher.
<script>
function getScreenBrightness() {
return Android.getScreenBrightness();
}
</script>
<a href="javascript:console.log(getScreenBrightness());">Get Screen Brightness</a>
Set Screen Brightness
Sets screen brightness (range of 1 - 255), requires version 1.43 or higher.
<script>
function setScreenBrightness(level) {
Android.setScreenBrightness(level);
}
</script>
<a href="javascript:setScreenBrightness(1);">Set Screen Brightness</a>
<a href="javascript:setScreenBrightness(255);">Set Screen Brightness</a>
Get Volume Level
Returns volume level of specified type, requires version 2.0.38 or higher.
<script>
var STREAM_ALARM = 4;
var STREAM_DTMF = 8;
var STREAM_MUSIC = 3;
var STREAM_NOTIFICATION = 5;
var STREAM_RING = 2;
var STREAM_SYSTEM = 1;
var STREAM_VOICE_CALL = 0;
function getVolumeLevel(type) {
return Android.getVolumeLevel(type);
}
</script>
<a href="javascript:showAndroidToast(getVolumeLevel(STREAM_NOTIFICATION));">Get Volume level</a>
Get Maximum Volume Level
Returns maximum volume level of specified type, requires version 2.0.38 or higher.
<script>
var STREAM_ALARM = 4;
var STREAM_DTMF = 8;
var STREAM_MUSIC = 3;
var STREAM_NOTIFICATION = 5;
var STREAM_RING = 2;
var STREAM_SYSTEM = 1;
var STREAM_VOICE_CALL = 0;
function getMaxVolumeLevel(type) {
return Android.getMaxVolumeLevel(type);
}
</script>
<a href="javascript:showAndroidToast(getMaxVolumeLevel(STREAM_NOTIFICATION));">Get Maximum Volume level</a>
Set Volume Level
Sets volume level of specified type, requires version 2.0.38 or higher.
<script>
var STREAM_ALARM = 4;
var STREAM_DTMF = 8;
var STREAM_MUSIC = 3;
var STREAM_NOTIFICATION = 5;
var STREAM_RING = 2;
var STREAM_SYSTEM = 1;
var STREAM_VOICE_CALL = 0;
function setVolumeLevel(type) {
//NOTE IF THE DEVICE IS SET TO DO NOT DISTURB THE VOLUME CANNOT BE CHANGED
//REQUIRES WHOLE NUMBER, VOLUME RANGE WILL DEPEND ON THE TYPE BEING SET
//50% VOLUME
var middle = Math.round(Android.getMaxVolumeLevel(STREAM_NOTIFICATION)/2);
showAndroidToast(middle);
return Android.setVolumeLevel(STREAM_NOTIFICATION, middle);
}
</script>
<a href="javascript:setVolumeLevel(STREAM_NOTIFICATION);">Set Volume level (50%)</a>
Get WiFi Signal
Returns WiFi signal strength (range of 0-4), requires version 2.5.6 or higher.
<script>
function getWiFiSignal() {
return Android.getWiFiSignal();
}
</script>
<a href="javascript:console.log(getWiFiSignal());">Get WiFi Signal</a>
Get Cell Signal
Returns Cell signal strength (range of 0-4), requires version 2.5.6 or higher + Android 4.2 or higher.
<script>
function getCellSignal() {
return Android.getCellSignal();
}
</script>
<a href="javascript:console.log(getCellSignal());">Get Cell Signal</a>
Get Cell Network Type
Returns Cell network type i.e. HSDPA, LTE etc... Requires version 2.5.6 or higher + Android 4.2 or higher.
<script>
function getCellNetworkType() {
return Android.getCellNetworkType();
}
</script>
<a href="javascript:console.log(getCellNetworkType());">Get Cell Network Type</a>
Enable/Disable Bluetooth
Enables or disables Bluetooth, requires version 2.5.7 or higher.
<script>
function setBluetoothEnabled(enabled) {
KBBluetooth.setWiFiEnabled(enabled);
}
</script>
<a href="javascript:setBluetoothEnabled(false);">Disable Bluetooth</a>
<a href="javascript:setBluetoothEnabled(true);">Enable Bluetooth</a>
Updated on: 03/03/2021
Thank you!