Android BluetoothClass - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android BluetoothClass class.

This code example shows how to use the following methods:getDeviceClass, getMajorDeviceClass
This code example shows how to use the following methods:getDeviceClass
		final BluetoothDevice btDevice = intent.getExtras().getParcelable(
				BluetoothDevice.EXTRA_DEVICE);
		if(btDevice != null) {
			final BluetoothClass btClass = btDevice.getBluetoothClass(); 
			if (btClass != null) {
				final int btDevClass = btClass.getDeviceClass();
				if ((btDevClass & remoteAudioClass) != 0) {
					SPApp.getInstance().unregisterProximityListener(); 
					SPApp.getInstance().setHeadsetConnected(true); 
					SPApp.log("Bluetooth headset has been connected"); 
				} 
			} 
		} 
	} 
} 
4
CodeRank
This code example shows how to use the following methods:getMajorDeviceClass
				Log.i(TAG, intent.getAction() + ": missing class information on device: " + bd); 
				return; 
			} 
			 
			Log.i(TAG, intent.getAction() + ": bluetooth class is " + bdc); 
			if (bdc.getMajorDeviceClass() != BluetoothClass.Device.Major.AUDIO_VIDEO) { 
				return; 
			} 
			 
			/* I don't actually know at this point if user will actually enable this device, 
			 * or whether it just remains "connected". Knowing this would be useful. 
			 */ 
			bluetoothAudio = intent.getAction().equals(BluetoothDevice.ACTION_ACL_CONNECTED); 
			Log.i(TAG, "Bluetooth plugged: " + bluetoothAudio); 
		} 
	}; 
 
	private final PhoneStateListener mPhoneListener = new PhoneStateListener() {
		@Override 
		public void onCallStateChanged(int state, String incomingNumber) { 
4
CodeRank
This code example shows how to use the following methods:getDeviceClass
                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. 
                        mAudioManager.setMode(AudioManager.MODE_IN_CALL); 
                        mIsCountDownOn = true; 
                        mCountDown.start(); 
 
                        // override this if you want to do other thing when the device is connected. 
                        onHeadsetConnected(); 
                    } 
3
CodeRank
This code example shows how to use the following methods:getDeviceClass
		final BluetoothDevice btDevice = intent.getExtras().getParcelable(
				BluetoothDevice.EXTRA_DEVICE);
		if(btDevice != null) {
			final BluetoothClass btClass = btDevice.getBluetoothClass();
			if (btClass != null) {
				final int btDevClass = btClass.getDeviceClass();
				if ((btDevClass & remoteAudioClass) != 0) {
					SPApp.getInstance().unregisterProximityListener(); 
					SPApp.getInstance().setHeadsetConnected(true); 
					SPApp.log("Bluetooth headset has been connected"); 
				} 
			} 
		} 
	} 
} 
4
CodeRank
This code example shows how to use the following methods:getMajorDeviceClass
			if (BluetoothDevice.ACTION_FOUND.equals(action)) { 
				// Get the BluetoothDevice object from the Intent 
				BluetoothDevice device = intent 
						.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 
				BluetoothClass bc = device.getBluetoothClass(); 
				if (bc.getMajorDeviceClass() == BluetoothClass.Device.Major.PHONE) { 
					BtFoundDevices.put(device.getAddress(), device.getName()); 
				} 
				Log.d(TAG, "Found " + device.getAddress()); 
 
			} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED 
					.equals(action)) { 
				// Do something when the search finishes. 
				Log.d(TAG, "Service Discovery Finished !"); 
			} else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { 
				/* 
				 * Check if Local bluetooth adapter is on or off and make 
				 * changes accordingly. 
				 */ 
 
4
CodeRank
This code example shows how to use the following methods:getMajorDeviceClass
This code example shows how to use the following methods:getDeviceClass
                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. 
                        mAudioManager.setMode(AudioManager.MODE_IN_CALL); 
                        mIsCountDownOn = true; 
                        mCountDown.start(); 
 
                        // override this if you want to do other thing when the device is connected. 
                        onHeadsetConnected(); 
                    } 
3
CodeRank
This code example shows how to use the following methods:getDeviceClass
		final BluetoothDevice btDevice = intent.getExtras().getParcelable(
				BluetoothDevice.EXTRA_DEVICE);
		if(btDevice != null) {
			final BluetoothClass btClass = btDevice.getBluetoothClass(); 
			if (btClass != null) {
				final int btDevClass = btClass.getDeviceClass();
				if ((btDevClass & remoteAudioClass) != 0) {
					SPApp.getInstance().unregisterProximityListener(); 
					SPApp.getInstance().setHeadsetConnected(true); 
					SPApp.log("Bluetooth headset has been connected"); 
				} 
			} 
		} 
	} 
} 
4
CodeRank

Related Android BluetoothClass Questions & Answers:

See Code Examples for Android BluetoothClass Methods: