Java Code Examples for android.bluetooth.BluetoothAdapter#SCAN_MODE_CONNECTABLE

The following examples show how to use android.bluetooth.BluetoothAdapter#SCAN_MODE_CONNECTABLE . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void onReceive(Context context, Intent intent) {
    SwitchCompat bluetoothSwitch = container.findViewById(R.id.switch_bluetooth);
    TextView textBluetoothVisible = container.findViewById(R.id.bluetooth_visible);
    if (bluetoothSwitch == null || textBluetoothVisible == null
            || !BluetoothManager.ACTION_STATUS.equals(intent.getAction())) {
        return;
    }
    switch (intent.getIntExtra(BluetoothAdapter.EXTRA_SCAN_MODE, -1)) {
        case BluetoothAdapter.SCAN_MODE_NONE:
            textBluetoothVisible.setText(R.string.disabled);
            bluetoothSwitch.setEnabled(true);
            break;

        case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE:
            textBluetoothVisible.setText(R.string.swap_visible_bluetooth);
            bluetoothSwitch.setEnabled(true);
            break;

        case BluetoothAdapter.SCAN_MODE_CONNECTABLE:
            textBluetoothVisible.setText(R.string.swap_not_visible_bluetooth);
            bluetoothSwitch.setEnabled(true);
            break;
    }
}
 
Example 2
Source Project: J2ME-Loader   File: LocalDevice.java    License: Apache License 2.0 5 votes vote down vote up
public int getDiscoverable() {
	int scanMode = DiscoveryAgent.adapter.getScanMode();
	switch (scanMode) {
		case BluetoothAdapter.SCAN_MODE_CONNECTABLE:
			return DiscoveryAgent.LIAC;
		case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE:
			return DiscoveryAgent.GIAC;
		case BluetoothAdapter.SCAN_MODE_NONE:
		default:
			return DiscoveryAgent.NOT_DISCOVERABLE;
	}
}
 
Example 3
@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getIntExtra(BluetoothAdapter.EXTRA_SCAN_MODE, -1)) {
        case BluetoothAdapter.SCAN_MODE_NONE:
            BluetoothManager.stop(SwapService.this);
            break;

        case BluetoothAdapter.SCAN_MODE_CONNECTABLE:
        case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE:
            BluetoothManager.start(SwapService.this);
            break;
    }
}