DroidScript wiki

(was AndroidScript) unofficial documentation by the community

User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

built_in:nxt_requestenable [2015/03/10 15:41] (current)
madlyr created
Line 1: Line 1:
 +====== RequestEnable ======
 +The **RequestEnable** function invokes system dialog box which could enable Bluetooth on tablet/​phone when Bluetooth is disabled. If Bluetooth is enabled, this function doesn'​t invoke any visible dialog box. Be careful when checking Bluetooth state immediately after this function by calling IsEnabled or IsBluetoothEnabled,​ while RequestEnable doesn'​t stop program execution, and there is no SetOnRequestEnabled method called after this function invoke. This function is internally invoked by ShowDevices method when Bluetooth is disabled.
 +====Example - If Bluetooth is not enabled call RequestEnable on app start====
 +<code javascript>​
 +function OnStart()
 +  // Create NXT remote controller object.
 +  var nxt = app.CreateNxt();​
 +  // If Bluetooth is not enabled, then call function which allows to enable it
 +  if (!nxt.IsBluetoothEnabled()) {
 +    nxt.RequestEnable();​
 +  }
built_in/nxt_requestenable.txt ยท Last modified: 2015/03/10 15:41 by madlyr