2

I have a registered BroadcastReceiver in my main activity. Activity sends a sticky in one of the tabs to trigger the broadcast receiver (TabActivity application).

Everything works fine, but when I restart the app the sticky is sent automatically (not triggered by user) and view is opened.

My question is: how is that possible? Did I misunderstand something? And how can I fix that?

MainActivity: OnCreate:

    registerReceiver(openOutgoingCall, new IntentFilter("OPENOUTGOINGCALL"));

BroadcastReceiver:

private BroadcastReceiver openOutgoingCall = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {

            Bundle extras = intent.getExtras();
            if(extras.isEmpty() == false) {
                HashMap<String,String> callData = (HashMap<String, String>) extras.get("callData");
                openOutgoingCall(callData); 
            }

        }
    };

Activity inside TabHost

public void openCall(View view) {
    Intent i = new Intent("OPENOUTGOINGCALL");
    i.putExtra("callData", detailInfo);
    sendStickyBroadcast(i);    
}
Nikolai Samteladze
  • 7,699
  • 6
  • 44
  • 70

1 Answers1

2

Sticky broadcasts are supposed to stay around (even they are received) so that they can be retrieved afterwards too. Perhaps you should try the simple way of broadcasting using:

sendBroadcast(i);

Read this.

Community
  • 1
  • 1
waqaslam
  • 67,549
  • 16
  • 165
  • 178