public void establishBluetoothConnection() { // TODO: Handdling the case of device not discoverable, but bluetooth ON. switch (btConnection.verifyBluetoothReady()) { case BluetoothConnection.BLUETOOTH_OFFLINE: mainActivity.showEnableBluetoothDialog(BluetoothAdapter.ACTION_REQUEST_ENABLE); break; case BluetoothConnection.NOT_HAVE_BLUETOOTH: mainActivity.showLongToastDialog("Dispositivo sem Bluetooth!"); break; case BluetoothConnection.BLUETOOTH_ONLINE: if (!isReceiverRegistered) { filterAction.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED); filterAction.addAction(BluetoothDevice.ACTION_FOUND); filterAction.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); filterAction.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); isReceiverRegistered = true; mainActivity.registerReceiver(btActionReceiver, filterAction); } btConnection.startDeviceDiscovery(); break; } }
private void registerLocationReceiver() { locationReceiver = new LocationUpdateReceiver(mainActivity); IntentFilter filter = new IntentFilter(UPDATE_LOCATION); mainActivity.registerReceiver(locationReceiver, filter); }
private void registerReceiver() { receiver = new AlarmReceiver(mainActivity); IntentFilter filter = new IntentFilter(ALARM_ACTION); mainActivity.registerReceiver(receiver, filter); }