Android - Intents somehow incrementing?

I have started using custom intents in my application and I have come across a bit of a problem.

When I send a custom intent I register a Broadcast Receiver and I catch the intent no problem.

However problems seem to appear when I send the intent again, the Broadcast Reciever seems to register two events of the intent and so on so if the intent is sent a third time I recieve it 3 times.

This is causing major problems in my application and was wondering is it normal and there is some way I have to deal with it?

Here is my code:


To Send the Intent:

Intent i = new Intent();
i.setAction(SIP_INCOMING_CALL_CANCEL_INTENT);
sendBroadcast(i);

To receive the Intent:

sipIncomingListener = new BroadcastReceiver(){

   @Override
   public void onReceive(Context context, Intent intent) {
      String action = intent.getAction(); 

      if(CallDialogActivity.SIP_INCOMING_CALL_ANSWER_INTENT.equals(action)){
         Log.d("SIPENGINE", "CALL CONNECTED SENT FROM INITINCOMINGLISTENER()");
      }  
   };

IntentFilter filter = new IntentFilter(CallDialogActivity.SIP_INCOMING_CALL_CANCEL_INTENT);
registerReceiver(sipIncomingListener, filter);

Is there anyway to make sure the Intent is only fired once??

Answers


I'm not sure, why you have this issue, but are you sure that you need a Broadcast(Receiver) to handle intents? Can you please explain, why do you do that?

Back to your problem: can you provide a simple minimalistic project? I think the issue is not in the code you provided.


Need Your Help

What am I doing wrong with this linq query (querying datatable)

c# winforms linq datatable

I am connecting my Windows Form app to their Access DB (ugh, I know), and cannot get my linq query to return anything.