I think everything is perfect in the code but I’m not able to receive the broadcast in the broadcast receiver.
Here is my ACTIVITY
public class BroadcastDemo extends Activity {
Button bt;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bt = (Button)findViewById(R.id.button1);
bt.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
Intent broadint = new Intent();
broadint.setAction("SENT_BROADCAST");
getApplicationContext().sendBroadcast(broadint);
Log.e("Dillu","BroadCast is sent");
}
});
}
}
Here is Broadcast Receiver
public class ReceiveBroadcast extends BroadcastReceiver{
@Override
public void onReceive(Context con,Intent inte){
Log.e("Dillu","Receiving the BroadCast");
if(inte.getAction().equals("SENT_BROADCAST"))
Toast.makeText(con, "Received BroadCast Succesfully", Toast.LENGTH_LONG).show();
Log.e("Dillu","Received the BroadCast");
}
}
Here is the Receiver registered in the Manifest file
<Receiver
android:name=".ReceiveBroadcast">
<intent-filter>
<action android:name="SENT_BROADCAST"></action>
</intent-filter>
</Receiver>
The Broadcast receiver is not able to receive the Broadcast sent from Activity. I don’t know where I have gone wrong.
I am not sure this would resolve your question, but I can see that your tag has capital “R”
<Receiver>tag should be<receiver>