Source:
private void registerReceivers() { this.broadcastRegistrar = new BroadcastRegistrar(); this.broadcastRegistrar .addLocalAction(ConnectionService.ACTION_FIND_FINISHED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { onFindFinished(intent); } }) .addLocalAction(UserList.ACTION_USER_LIST_UPDATE, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { updateUserView(); } }) .addLocalAction(ConnectionService.ACTION_GUEST_CONNECTED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { setDisconnectDisbandBtn(); } }) .addLocalAction(ConnectionService.ACTION_HOST_CONNECTED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { setDisconnectDisbandBtn(); } }) .addLocalAction(ConnectionService.ACTION_HOST_DISCONNECTED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { Log.i(TAG, "Host Disconnected"); cleanUpAfterDisconnect(); } }) .addGlobalAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { int mode = intent.getIntExtra( BluetoothAdapter.EXTRA_SCAN_MODE, BluetoothAdapter.SCAN_MODE_NONE); if(joinDifferentNetworkButton != null){ switch(mode){ case BluetoothAdapter.SCAN_MODE_NONE: setButtonToDefaultState(joinDifferentNetworkButton); isSearchingJoinDifferent = false; break; case BluetoothAdapter.SCAN_MODE_CONNECTABLE: setButtonToDefaultState(joinDifferentNetworkButton); isSearchingJoinDifferent = false; break; case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE: setButtonToSearchingState(joinDifferentNetworkButton); isSearchingJoinDifferent = true; break; default: Log.wtf(TAG, "Recieved scan mode changed with unknown mode"); break; } } } }) .register(this.getActivity()); }

Target:
private void registerReceivers() { this.broadcastRegistrar = new BroadcastRegistrar(); this.broadcastRegistrar .addLocalAction(ConnectionService.ACTION_FIND_FINISHED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { onFindFinished(intent); } }) .addLocalAction(UserList.ACTION_USER_LIST_UPDATE, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { updateUserView(); } }) .addLocalAction(ConnectionService.ACTION_GUEST_CONNECTED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { setDisconnectDisbandBtn(); } }) .addLocalAction(ConnectionService.ACTION_HOST_CONNECTED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { setDisconnectDisbandBtn(); } }) .addLocalAction(ConnectionService.ACTION_HOST_DISCONNECTED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { Log.i(TAG, "Host Disconnected"); cleanUpAfterDisconnect(); } }) .addGlobalAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED, new IBroadcastActionHandler() { @Override public void onReceiveAction(Context context, Intent intent) { int mode = intent.getIntExtra( BluetoothAdapter.EXTRA_SCAN_MODE, BluetoothAdapter.SCAN_MODE_NONE); if(joinDifferentNetworkButton != null){ switch(mode){ case BluetoothAdapter.SCAN_MODE_NONE: case BluetoothAdapter.SCAN_MODE_CONNECTABLE: setButtonToDefaultState(joinDifferentNetworkButton); isSearchingJoinDifferent = false; break; case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE: setButtonToSearchingState(joinDifferentNetworkButton); isSearchingJoinDifferent = true; break; default: Log.wtf(TAG, "Recieved scan mode changed with unknown mode"); break; } } } }) .register(this.getActivity()); }