Max Spirin
Jan 21, 2019
3:00 pm

Enabling and Pairing Bluetooth while in ProKiosk mode

I can use some help trying to get Bluetooth pairing to work while in ProKiosk mode.

Currently. my code "enables" Bluetooth to the extent that I see the Bluetooth icon in the status bar. However, while in ProKiosk mode, when I try

to "see" it from other devices - phones and cars - these devices do not show it in their list of available BT devices.

 

Anybody have an example of how to accomplish this using the 3.2.1 API?

Mikayla N.Samsung SEAP Moderator
Jan 22, 2019
5:34 pm

Hi Max,

Enabling Bluetooth in ProKiosk mode should allow other devices to discover and pair with your device. However, I have been able to recreate your issue and confirm that devices are currently unable to pair with a device in ProKiosk mode. We are looking into it. 

Best,

Mikayla

Comments

Post Deleted

Our content monitors have determined that this post violated our terms of service.

Please ensure your posts comply with our forum guidelines. We are committed to providing helpful and professional information in this space.

Thank you,

The SEAP team

Deleted Jan 24, 2019 9:33 pm

Mikayla N.Samsung SEAP Moderator
Jan 24, 2019
5:57 pm

Hi Max,

Android devices are only discoverable if they are open to the Bluetooth Settings page. This is why you are unable to see the device when it is in ProKiosk mode. However, the Android class BluetoothAdapter has some methods that may help you work around this, specifically the startDiscovery() method. https://developer.android.com/reference/android/bluetooth/BluetoothAdapt...

Best,

Mikayla

Comments

Mikayla ---

I am calling startDiscovery but it looks like the system dialog that would normally appear is blocked because the app is in ProKiosk mode.

public boolean setBluetoothAgain(boolean enable) {
    EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(mContext);
    BluetoothPolicy bluetoothPolicy = edm.getBluetoothPolicy();

    try {
        boolean pairResult = bluetoothPolicy.setPairingState(enable);
        Log.d(TAG, "bluetoothPolicy.setPairingState: " + pairResult);
        boolean discoverResult = bluetoothPolicy.setDiscoverableState(enable);
        Log.d(TAG, "bluetoothPolicy.setPairingState: " + discoverResult);
    } catch (SecurityException e) {
        Log.d(TAG, "SecurityException: " + e.getLocalizedMessage());
    }

    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    boolean isEnabled = bluetoothAdapter.isEnabled();
    if (enable && !isEnabled) {
        boolean btEnabled = bluetoothAdapter.enable();
        Log.d(TAG, "bluetoothAdapter.enable: " + btEnabled);
        boolean btDiscover = bluetoothAdapter.startDiscovery();
        Log.d(TAG, "bluetoothAdapter.startDiscovery: " + btDiscover);
        return btEnabled;
    } else if (!enable && isEnabled) {
        return bluetoothAdapter.disable();
    }
    // No need to change bluetooth state
    return true;
}

 

Other ideas?

Max

Max SpirinJan 24, 2019 at 6:32 pm
Mikayla N.Samsung SEAP Moderator
Jan 24, 2019
10:23 pm

Hi Max,

The workaround I provided is a programmatic way of discovering devices. When using this method, it won't show a system dialog. You will need to implement a broadcast receiver that will list all devices that are discovered. This method works regardless of whether you are in pro kiosk mode or not. It's explained in detail in the Android developer guide: https://developer.android.com/guide/topics/connectivity/bluetooth#DiscoverDevices

Once the device is discovered, you can connect to it using the steps described in the developer guide as well. 

Best,

Mikayla