0

Not works on 2.3. But works on 4.0.x. Why?

Sending from IntentService:

intent.setAction(MessagesThread.NEW_MESSAGE);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);

Receiving

protected void onStart() {
super.onStart();
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,new IntentFilter(NEW_MESSAGE));
}

protected void onStop() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
super.onStop();
}

private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
    .......................................
            .......................................
}
};
GPPSoft
  • 480
  • 1
  • 6
  • 15

2 Answers2

0

I am not sure, but the issue might be due to LocalBroadcastManager. Try sending broadcast without using LocalBroadcastManager, like below:

SEND BROADCAST

Intent i = new Intent("ALERT_CHANGE");
i.putExtra("DATA","News");
sendBroadcast(i);

RECEIVE BROADCAST-in Activity

registerReceiver(uiUpdated, new IntentFilter("ALERT_CHANGE"));


private BroadcastReceiver uiUpdated= new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) 
{
String DATA = i.getStringExtra("Data");
txt.settext(DATA);
}
};
Parth Kapoor
  • 1,494
  • 12
  • 23
0
LocalBroadcastManager.getInstance(this).sendBroadcast(newIntent(MessagesThread.NEW_MESSAGE).putExtras(intent));
Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79
GPPSoft
  • 480
  • 1
  • 6
  • 15