Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get list of all BroadcastReceiver(s) registered for a specific intent?

I am developing an android service at OS level. ( not from SDK, its from android source code. It will be part of my custom ROM. I can tun myself as root)

I am going to give an interface to apps to do something using my custom intent. At the end I want to know who all are listening for this intent.

Is there any way to get list of all BroadcastReceiver(s) registered for a specific intent?

Thanks for help!

like image 224
Pratik Avatar asked Apr 24 '13 22:04

Pratik


People also ask

How do I check if BroadcastReceiver is registered?

public boolean isReceiverRegistered(BroadcastReceiver receiver); It would return true if it's registered and false if not.

Which intent is used by BroadcastReceiver?

Creating a BroadcastReceiverThe intent object is passed with all the additional data. A Context object is also available and is used to start an activity or service using context. startActivity(myIntent); or context.

What is the role of the onReceive () method in the BroadcastReceiver?

Retrieve the current result data, as set by the previous receiver. Retrieve the current result extra data, as set by the previous receiver. This can be called by an application in onReceive(Context, Intent) to allow it to keep the broadcast active after returning from that function.

How do I know if my kotlin broadcast receiver is registered?

A simple solution to this problem is to call the registerReceiver() in your Custom Application Class. This will ensure that your Broadcast receiver will be called only one in your entire Application lifecycle.


1 Answers

From a program you can use PackageManager and queryBroadcastReceivers().

From the 'adb shell', try the command: dumpsys activity

the Activity Resolver Table lists all the things that broadcast receivers are looking for.

like image 122
CommonsWare Avatar answered Nov 11 '22 09:11

CommonsWare