title: AlertDialog show = new AlertDialog.Builder(this) is Undefined
body: <p>The app intercepts sms messages and displays a <code>Dialog</code> of the message. </p>
  
  <p>However I am unable to get my <code>Dialog</code> error resolved in my <code>Test</code> class. What am I doing wrong?</p>
  
  <p>(I've also included my other 2 files).</p>
  
  <p>ERROR shown in Eclipse: <code>AlertDialog.Builder(Test) is undefined</code></p>
  
  <hr>
  
  <p><strong>test.java</strong></p>
  
  <pre><code>package com.example.firstapp;
  
  import android.app.AlertDialog;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.telephony.SmsMessage;
  
  public class Test extends BroadcastReceiver
  {
      @Override
      public void onReceive(Context context, Intent intent) 
      {
          //---get the SMS message passed in---
          Bundle bundle = intent.getExtras();        
          SmsMessage[] msgs = null;
          String str = "";            
          if (bundle != null)
          {
              //---retrieve the SMS message received---
              Object[] pdus = (Object[]) bundle.get("pdus");
              msgs = new SmsMessage[pdus.length];            
              for (int i=0; i&lt;msgs.length; i++){
                  msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);                
                  str += "SMS from " + msgs[i].getOriginatingAddress();                     
                  str += " :";
                  str += msgs[i].getMessageBody().toString();
                  str += "\n";                  
              }
  
              AlertDialog show = new AlertDialog.Builder(this)
              .setTitle("Message")
              .setMessage(str)
              .setNeutralButton("OK", null)
              .show();
      }                         
  }
  </code></pre>
  
  <p>}</p>
  
  <hr>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.firstapp"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="9"
          android:targetSdkVersion="15" /&gt;
      &lt;uses-permission android:name="android.permission.SEND_SMS"&gt;
      &lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_SMS"&gt;
      &lt;/uses-permission&gt;
      &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name=".Hello"
              android:label="@string/title_activity_hello" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;receiver android:name=".test"&gt; 
              &lt;intent-filter&gt; 
                  &lt;action android:name=
                      "android.provider.Telephony.SMS_RECEIVED" /&gt; 
              &lt;/intent-filter&gt; 
          &lt;/receiver&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>hello.java</strong></p>
  
  <pre><code>package com.example.firstapp;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  
  public class Hello extends Activity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.activity_hello);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.activity_hello, menu);
          return true;
      }  
  }
  </code></pre>