Broadcastreceiver onreceive not called
<p>I am sending a broadcast from one of my classes:</p>

<pre><code>    // Sending broadcast from my db helper constructor
    public DBHelper(Context ctx){
    this.ctx = ctx;
    Intent intent = new Intent();
    intent.setAction("custom.alert.abc");
    intent.putExtra("key",77);ctx.sendBroadcast(intent);




    //registering the broadcast in one of my activities oncreate
     IntentFilter alaramfilter = new IntentFilter();
    alaramfilter.addAction("custom.alert.abc");
     registerReceiver(alarmreceiver, alaramfilter); 

    //and declaring it
    private final BroadcastReceiver alarmreceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
    System.out.println("Broadcast received inside on receive");
    final String action = intent.getAction();
    if(action.equals("custom.alert.abc")) {
        Log.d("CPSnippetMain","My custom broadcast called");
        try {
             System.out.println("Broadcast received");
         } catch (Exception e) {
            e.printStackTrace();
        }
   }
}
};
</code></pre>

<p>The problem is, though the constructor is called, and broadcast is sent, onreceive is not called.</p>

<p>Any help is appreciated.</p>
