Code example for BluetoothDevice

Methods: getBluetoothClassgetName

            String action = intent.getAction(); 
            if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) 
                mConnectedHeadset = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 
                BluetoothClass bluetoothClass = mConnectedHeadset.getBluetoothClass(); 
                if (bluetoothClass != null) 
                    // Check if device is a headset. Besides the 2 below, are there other  
                    // device classes also qualified as headset? 
                    int deviceClass = bluetoothClass.getDeviceClass(); 
                    if (deviceClass == BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE  
                        || deviceClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET) 
                        // start bluetooth Sco audio connection. 
                        // Calling startBluetoothSco() always returns faIL here,  
                        // that why a count down timer is implemented to call 
                        // startBluetoothSco() in the onTick. 
                        mIsCountDownOn = true; 
                        // override this if you want to do other thing when the device is connected. 
                Log.d(TAG, mConnectedHeadset.getName() + " connected"); //$NON-NLS-1$ 
            else if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) 
                Log.d(TAG, "Headset disconnected"); //$NON-NLS-1$ 
Contextual code suggestions in your IDE  Get Codota for Java