BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (bluetoothAdapter == null) {
// bluetooth disabled/not available
}
else {
context.registerReceiver(new BluetoothListener(), new IntentFilter(BluetoothDevice.ACTION_FOUND));
if (bluetoothAdapter == null) {
// bluetooth disabled/not available
}
else {
context.registerReceiver(new BluetoothListener(), new IntentFilter(BluetoothDevice.ACTION_FOUND));
bluetoothAdapter.startDiscovery();
}
}
private class BluetoothListener extends BroadcastReceiver {
@Override
public void onReceive(Context c, Intent intent) {
BluetoothDevice rbd = (BluetoothDevice)intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// ...@Override
public void onReceive(Context c, Intent intent) {
BluetoothDevice rbd = (BluetoothDevice)intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
}
}
No comments:
Post a Comment