Android - are intentions somehow increasing?

I started using custom intentions in my application, and I ran into some problem.

When I submit a custom intent, I register a broadcast receiver and I will not catch the intent without a problem.

Be that as it may, problems appear when I send the intention again, the broadcast receiver seems to be recording two intent events and so on, so if the intention is sent a third time, I get it 3 times.

This causes serious problems in my application and wonders if this is normal, and somehow I have to deal with it?

Here is my code:


Send Intention:

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

To get the intention:

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);

In any case, to make sure that the intent is only triggered once?

+3
1

, , , () ? , ?

: ? , , .

+2

Source: https://habr.com/ru/post/1734865/


All Articles