Check if the broadcstreceiver is registered?

android, broadcastreceiver

Solution

You may want to use queryBroadcastReceivers to see if there is a receiver for your intent or not. If you are facing problem of multiple receiver registration, you may want to see this

Problem

Is there any way to check if the broadcast receiver is working or not. I did it like below. I register the broadcast receiver but it doesn't find this registered receiver.. ``` PackageManager pm = getApplicationContext().getPackageManager(); final List<PackageInfo> packs = pm.getInstalledPackages(PackageManager.GET_RECEIVERS); for (final PackageInfo p : packs) { ActivityInfo[] receivers = p.receivers; if (receivers != null) { for (ActivityInfo ai : receivers) { if(AppDetectionService.class.getName().equals(ai.name)){ onOff[2] = true; } } } } ```

Original source

Related problems