Search code examples
androidbluetoothbroadcastreceiverlocalbroadcastmanager

Receiver of LocalBroadcast not working for System broadcast


I have a service from where i can broadcast using LocalBroadcastManager.

Intent downloadIntent = new Intent();
downloadIntent.setAction(BroadcastActions.DOWNLOAD_APPOINTMENTS.toString());
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(downloadIntent);

In a Test activity i m receiving this broadcasts like following.

IntentFilter filter = new IntentFilter();
filter.addAction(String.valueOf(BroadcastActions.DOWNLOAD_APPOINTMENTS));
filter.addAction(BluetoothDevice.ACTION_FOUND);
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter);

In the same Test activity i added another action called ACTION_FOUND to get bluetooth enabled device. Since i m using LocalBroadCast Manager i couldn't receive broadcast of system if it found any bluetooth devices. Can anybody help on this to receive both system and local broadcasts..?


Solution

  • Can anybody help on this to receive both system and local broadcasts..?

    A LocalBroadcastReceiver is only useful within your own app hence the use of the term "local".

    There's nothing stopping you from using more than one BroadcastReceiver though. Simply create another one to receive the system broadcasts.