I’ve been trying to find out what is wrong here for a couple of hours. Why this broadcast reciever does not recieve the intent ?
static class BReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
Toast.makeText(context, "Got the intent", Toast.LENGTH_LONG).show();
}
}
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLayout = new FrameLayout(this);
setContentView(mLayout);
final IntentFilter intentFilter = new IntentFilter("com.example.testui.action");
getApplicationContext().registerReceiver(new BReceiver(), intentFilter);
final Intent intent = new Intent(getApplicationContext(), BReceiver.class);
intent.setAction("com.example.testui.action");
getApplicationContext().sendBroadcast(intent);
}
PS. I didn’t define this reciever in a manifest file, because, strictly saying, it is not mandatory.
Try to send broadcast this way: