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

Changing DATADIRECTORY location using CREATE TABLE is not working

mysql database linux create-table

I am trying to create a mysql table with changing data directory location by using the following code in LINUX. Unfortunately, it is created in the default location instead of specified location.

Need IPv6 Traffic Generator

c++ networking ipv6

I am looking for the tool to generator IPv6 Traffic. It should allow me to give all its header value manually by me.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.