Skip to content

Instantly share code, notes, and snippets.

@tylertreat
Created December 31, 2014 21:06
Show Gist options
  • Save tylertreat/a36233736b42a36619aa to your computer and use it in GitHub Desktop.
Save tylertreat/a36233736b42a36619aa to your computer and use it in GitHub Desktop.
private class BluetoothReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Found a Bluetooth device
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
onDeviceFound(device); // Do something with it
} else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
// Discovery has started, display progress spinner
setProgressBarIndeterminateVisibility(true);
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
// Discovery has ended, hide progress spinner
setProgressBarIndeterminateVisibility(false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment