title: Why am I getting the message 'Youractivity.java is not an activity subclass or alias'
body: <p>I created my own Android project and cut and pasted the code from this exercise:</p>
  
  <p><a href="http://androidexample.com/Show_Phone_Contacts_In_AutoComplete_Suggestions_-_Android_Example%20/index.php?view=article_discription&amp;aid=106&amp;aaid=128#" rel="nofollow noreferrer">http://androidexample.com/Show_Phone_Contacts_In_AutoComplete_Suggestions_-_Android_Example%20/index.php?view=article_discription&amp;aid=106&amp;aaid=128#</a></p>
  
  <p>When I build the project I get no errors or warnings. When I run the project I get this window with an error:</p>
  
  <p><a href="https://i.stack.imgur.com/3QRp3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3QRp3.png" alt="enter image description here"></a></p>
  
  <p>Annoyingly, I can't make the window any smaller, so I can't click any of the buttons. I just cick the 'X' at the top, to close it.</p>
  
  <p>Here's my project structure:</p>
  
  <p><a href="https://i.stack.imgur.com/QuRF9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QuRF9.png" alt="enter image description here"></a></p>
  
  <p>Where is it getting 'AutocompleteMain' from? (note the small c) My class is named AutoCompleteMain. Thanks for any help.</p>
  
  <p>And I do have the activity included in my Android Manifest, in case you're wondering:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.androidexample.autocompleteedittext"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"&gt;&lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="8" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.example.chris.dialler.AutoCompleteMain"
              android:label="@string/app_name"  &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;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here's the code of my class, AutoCompleteMain.java :</p>
  
  <p>(one thing I notice, in this class, is that phoneNumber.toString() and name.toString() are highlighted, saying they're redundant. Don't know if that's the cause of the problem)</p>
  
  <pre><code>package com.example.chris.dialler;
  
  import java.util.ArrayList;
  import android.app.Activity;
  import android.content.ContentResolver;
  import android.database.Cursor;
  import android.os.Bundle;
  import android.provider.ContactsContract;
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.inputmethod.InputMethodManager;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.AutoCompleteTextView;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.AdapterView.OnItemSelectedListener;
  import com.androidexample.autocompleteedittext.R;
  
  public class AutoCompleteMain extends Activity implements  OnItemClickListener, OnItemSelectedListener  {
  
      // Initialize variables
  
      AutoCompleteTextView textView=null;
      private ArrayAdapter&lt;String&gt; adapter;
  
      // Store contacts values in these arraylist
      public static ArrayList&lt;String&gt; phoneValueArr = new ArrayList&lt;String&gt;();
      public static ArrayList&lt;String&gt; nameValueArr = new ArrayList&lt;String&gt;();
  
      EditText toNumber=null;
      String toNumberValue="";
  
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle bundle) {
          super.onCreate(bundle);
  
          setContentView(R.layout.autocomplete_main);
  
          final Button Send = (Button) findViewById(R.id.Send);
  
          // Initialize AutoCompleteTextView values
  
          textView = (AutoCompleteTextView) findViewById(R.id.toNumber);
  
          //Create adapter
          adapter = new ArrayAdapter&lt;String&gt;
                  (this, android.R.layout.simple_dropdown_item_1line, new ArrayList&lt;String&gt;());
          textView.setThreshold(1);
  
          //Set adapter to AutoCompleteTextView
          textView.setAdapter(adapter);
          textView.setOnItemSelectedListener(this);
          textView.setOnItemClickListener(this);
  
          // Read contact data and add data to ArrayAdapter
          // ArrayAdapter used by AutoCompleteTextView
  
          readContactData();
  
  
          /********** Button Click pass textView object ***********/
          Send.setOnClickListener(BtnAction(textView));
  
  
      }
  
      private OnClickListener BtnAction(final AutoCompleteTextView toNumber) {
          return new OnClickListener() {
  
              public void onClick(View v) {
  
                  String NameSel = "";
                  NameSel = toNumber.getText().toString();
  
  
                  final String ToNumber = toNumberValue;
  
  
                  if (ToNumber.length() == 0 ) {
                      Toast.makeText(getBaseContext(), "Please fill phone number",
                              Toast.LENGTH_SHORT).show();
                  }
                  else
                  {
                      Toast.makeText(getBaseContext(), NameSel+" : "+toNumberValue,
                              Toast.LENGTH_LONG).show();
                  }
  
              }
          };
      }
  
  
      // Read phone contact name and phone numbers
  
      private void readContactData() {
  
          try {
  
              /*********** Reading Contacts Name And Number **********/
  
              String phoneNumber = "";
              ContentResolver cr = getBaseContext()
                      .getContentResolver();
  
              //Query to get contact name
  
              Cursor cur = cr
                      .query(ContactsContract.Contacts.CONTENT_URI,
                              null,
                              null,
                              null,
                              null);
  
              // If data data found in contacts
              if (cur.getCount() &gt; 0) {
  
                  Log.i("AutocompleteContacts", "Reading   contacts........");
  
                  int k=0;
                  String name = "";
  
                  while (cur.moveToNext())
                  {
  
                      String id = cur
                              .getString(cur
                                      .getColumnIndex(ContactsContract.Contacts._ID));
                      name = cur
                              .getString(cur
                                      .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
  
                      //Check contact have phone number
                      if (Integer
                              .parseInt(cur
                                      .getString(cur
                                              .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) &gt; 0)
                      {
  
                          //Create query to get phone number by contact id
                          Cursor pCur = cr
                                  .query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                                          null,
                                          ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                                  + " = ?",
                                          new String[] { id },
                                          null);
                          int j=0;
  
                          while (pCur
                                  .moveToNext())
                          {
                              // Sometimes get multiple data
                              if(j==0)
                              {
                                  // Get Phone number
                                  phoneNumber =""+pCur.getString(pCur
                                          .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
  
                                  // Add contacts names to adapter
                                  adapter.add(name);
  
                                  // Add ArrayList names to adapter
                                  phoneValueArr.add(phoneNumber.toString());
                                  nameValueArr.add(name.toString());
  
                                  j++;
                                  k++;
                              }
                          }  // End while loop
                          pCur.close();
                      } // End if
  
                  }  // End while loop
  
              } // End Cursor value check
              cur.close();
  
  
          } catch (Exception e) {
              Log.i("AutocompleteContacts","Exception : "+ e);
          }
  
  
      }
  
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int position,
                                 long arg3) {
          // TODO Auto-generated method stub
          //Log.d("AutocompleteContacts", "onItemSelected() position " + position);
      }
  
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          // TODO Auto-generated method stub
  
          InputMethodManager imm = (InputMethodManager) getSystemService(
                  INPUT_METHOD_SERVICE);
          imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
  
      }
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {
          // TODO Auto-generated method stub
  
          // Get Array index value for selected name
          int i = nameValueArr.indexOf(""+arg0.getItemAtPosition(arg2));
  
          // If name exist in name ArrayList
          if (i &gt;= 0) {
  
              // Get Phone Number
              toNumberValue = phoneValueArr.get(i);
  
              InputMethodManager imm = (InputMethodManager) getSystemService(
                      INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
  
              // Show Alert
              Toast.makeText(getBaseContext(),
                      "Position:"+arg2+" Name:"+arg0.getItemAtPosition(arg2)+" Number:"+toNumberValue,
                      Toast.LENGTH_LONG).show();
  
              Log.d("AutocompleteContacts",
                      "Position:"+arg2+" Name:"+arg0.getItemAtPosition(arg2)+" Number:"+toNumberValue);
  
          }
  
      }
  
      protected void onResume() {
          super.onResume();
      }
  
      protected void onDestroy() {
          super.onDestroy();
      }
  
  }
  </code></pre>