Samsung Electronics logo

Managing the Bluetooth Service



Learning how to enable or disable the Bluetooth service and add a device name is a basic Bluetooth management skill:

  1. Retrieve a BluetoothAdapter object with the getDefaultAdapter() method:

    var adapter = webapis.bluetooth.getDefaultAdapter();
    
  2. Enable or disable the Bluetooth adapter using the setPowered() method:

    /* Enable Bluetooth */
    adapter.setPowered(true, function() 
    {
       console.log("Bluetooth powered on successfully.");
    });
    
    /* Disable Bluetooth */
    adapter.setPowered(false, function() 
    {
       webapis.application.exit();
    });
    
  3. Give the device a unique name by using the setName() method.

    The name helps to recognize devices in a list of retrieved active devices.

    adapter.setName(chatServerName);