title: Unable to start activity ComponentInfo : NullPointerException
body: <p>I am not so new to android development, but I am not able to figure out why this silly issue is coming up. All I am doing is starting an activity on application start and it crashes giving <code>nullpointerException</code>. Please check my code below. </p>
  
  <p>May be last-office-hours are making me blind.</p>
  
  <p>Logcat: </p>
  
  <pre><code>08-23 18:19:19.359: E/AndroidRuntime(798): FATAL EXCEPTION: main
  08-23 18:19:19.359: E/AndroidRuntime(798): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.click4tab.orderformnew/com.click4tab.orderformnew.Login}: java.lang.NullPointerException
  </code></pre>
  
  <p>Login.java :     </p>
  
  <pre><code>public class Login extends Activity {
  
      Button loginButton;
      EditText id, password;
      String sID, sPassword;
      TestAdapter obj;
      Context loginContext;
      public static int loginSuccessful;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.login);
  
          //Initialising variables 
  
          loginButton = (Button)findViewById(R.id.button1);
          id = (EditText)findViewById(R.id.editText1);
          password = (EditText)findViewById(R.id.editText2);
  
          obj = new TestAdapter(loginContext);
  
  
          sID = id.getText().toString();
          sPassword = password.getText().toString();
  
          StringBuffer buf = new StringBuffer();
          buf.append(sID + ":::" + sPassword);
  
  
          TestAdapter.params = new ArrayList&lt;NameValuePair&gt;();
          TestAdapter.params.add(new BasicNameValuePair("tag", "login"));
          TestAdapter.params.add( new BasicNameValuePair("query", buf.toString()));
  
          loginButton.setOnClickListener( new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
  
                  //send login information to authenticate user
  
                  obj.new Read().execute("");
  
  //              Intent i = new Intent("mainActivity");
  //              startActivity(i);
  
              }
          });
  
      }
  
  
  
  }
  </code></pre>
  
  <p>Manifest: </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.click4tab.orderformnew"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk android:minSdkVersion="15" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  
      &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name" &gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="mainActivity" /&gt;
  
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:name=".Login"
              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;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>login.xml : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" &gt;
  
          &lt;TextView
              android:id="@+id/textView1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_alignParentTop="true"
              android:layout_marginTop="194dp"
              android:text="ID"
              android:textAppearance="?android:attr/textAppearanceMedium" /&gt;
  
  
          &lt;EditText
              android:id="@+id/editText1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignBaseline="@+id/textView1"
              android:layout_alignBottom="@+id/textView1"
              android:layout_alignLeft="@+id/button1"
              android:ems="10" &gt;
  
              &lt;requestFocus /&gt;
          &lt;/EditText&gt;
  
          &lt;TextView
              android:id="@+id/textView2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_below="@+id/editText1"
              android:layout_marginTop="29dp"
              android:text="Password"
              android:textAppearance="?android:attr/textAppearanceMedium" /&gt;
  
  
  
  
          &lt;EditText
              android:id="@+id/editText2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignBaseline="@+id/textView2"
              android:layout_alignBottom="@+id/textView2"
              android:layout_alignLeft="@+id/button1"
              android:layout_alignParentRight="true"
              android:ems="10"
              android:inputType="textPassword" /&gt;
  
  
          &lt;Button
              android:id="@+id/button1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_below="@+id/editText2"
              android:layout_centerHorizontal="true"
              android:layout_marginLeft="19dp"
              android:layout_marginTop="16dp"
              android:text="Login" /&gt;
  
      &lt;/RelativeLayout&gt;
  </code></pre>