title: Listen to hardware button click event in android
body: <p>As a simple test I'm trying to have a broadcastReceiver that will notify the user with a Toast message that an hardware button was clicked in android.</p>
  
  <p>I've created a receiver tag in my manifest file with a name .TestReceiver that listens to Action_CALL_BUTTON to be informed when the user clicks on the green SEND button:</p>
  
  <pre><code>&lt;receiver android:name=".TestReceiver" &gt;
      &lt;intent-filter&gt;             
          &lt;action android:name="android.intent.action.ACTION_CALL_BUTTON" /&gt;
      &lt;/intent-filter&gt;            
  &lt;/receiver&gt;
  </code></pre>
  
  <p>Next, I created the TestReceiver class that extends BroadcastReceiver and creates a Toast.
  When I click on the call button I don't see the Toast message but I tested it on an activity and it shows.
  What am I missing here?</p>
  
  <pre><code>package com.example.helloandroid;
  
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.widget.Toast;
  
  public class TestReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          // TODO Auto-generated method stub
  
          CharSequence text = "Hello toast!";
          int duration = Toast.LENGTH_SHORT;
  
          Toast toast = Toast.makeText(context, text, duration);
          toast.show();
  
      }
  
  }
  </code></pre>
  
  <p>Thanks</p>