title: Android app force closes while going on another activity
body: <p>I am making an android app using android 2.2 and eclipse. </p>
  
  <p>There are two workflows of the app:</p>
  
  <p><strong>WF1:</strong> <code>CoverPageApp -&gt; LoginActivity -&gt; Dashboard.</code></p>
  
  <p><strong>WF2:</strong> <code>CoverPageApp -&gt; RegisterActivity -&gt; Dashboard.</code></p>
  
  <p>But as I click on the Start Button in CoverPageApp to go on another activity, i.e LoginActivity, the app force closes. 
  I have also included the LogCat which shows error of Null Exception and in the LoginActivity Java File it points on the line 51: 
   <code>btnLinkToRegistrScrn = (Button) findViewById(R.id.LinkToRegisterScreen);</code></p>
  
  <p><strong>AndroidManifest.xml</strong></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.app.android"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk android:targetSdkVersion="15" android:minSdkVersion="8" /&gt;
  
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&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:enabled="true"
              android:name=".PageApp"
              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;activity 
              android:enabled="true"
              android:name=".LoginActivity1"
              android:label="Login Activity" &gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:enabled="true"
              android:name=".CAActivity"
              android:label="Register Activity" &gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:enabled="true"
              android:name=".DashboardActivity"
              android:label="Dashboard Activity" &gt;
          &lt;/activity&gt;
  
      &lt;/application&gt;
  
    &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>PageApp.java</strong></p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  //import android.content.Context;
  import android.content.Intent;
  import android.widget.Button;
  import android.view.View;
  
  public class PageApp extends Activity {
  
      Button startbutton;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.coverpage);
          addListenerOnButton();
     }
  
  
      public void addListenerOnButton() {
  
          //final Context context1 = this;
  
          startbutton = (Button) findViewById(R.id.button1);
  
          startbutton.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
                  Intent intent1 = new Intent(arg0.getContext(), LoginActivity1.class); 
              //    intent1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                  startActivity(intent1); 
                  finish();
                  }
              });
  
      }
  
  }
  </code></pre>
  
  <p><strong>Log.java</strong></p>
  
  <pre><code>import android.app.Activity;
  //import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  //import android.view.View.OnClickListener;
  import android.widget.Button;
  //import android.widget.TextView;
  
  
  public class Log extends Activity {
  
      Button btnLinkToRegistrScrn;
      Button loginbtn1;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
       setContentView(R.layout.login);
       addListenerOnButton();
  //     btnLinkToRegistrScrn = (Button) findViewById(R.id.LinkToRegisterScreen); 
  
     }
  
  
      public void addListenerOnButton() {
  
          //final Context context2 = this;
  
              loginbtn1 = (Button) findViewById(R.id.btnLogin);
  
              loginbtn1.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
  
                  Intent intent = new Intent(arg0.getContext(), DashboardActivity.class);
                  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                           startActivity(intent);   
              }
  
          });
      }
  
  
      { 
          // Link to Register Screen 
          btnLinkToRegistrScrn = (Button) findViewById(R.id.LinkToRegisterScreen); 
          btnLinkToRegistrScrn.setOnClickListener(new View.OnClickListener() { 
             @Override
              public void onClick(View v) { 
                  Intent i = new Intent(v.getContext(), CAaactivity.class); 
                //  i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                  startActivity(i);
                  } 
         }); 
  
      }   
  
     }
  </code></pre>
  
  <p><strong>LOGCAT</strong></p>
  
  <pre><code>05-31 17:53:19.691: D/AndroidRuntime(1958): Shutting down VM
  05-31 17:53:19.710: W/dalvikvm(1958): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
  05-31 17:53:19.730: E/AndroidRuntime(1958): FATAL EXCEPTION: main
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at android.os.Handler.dispatchMessage(Handler.java:99)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at android.os.Looper.loop(Looper.java:123)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at android.app.ActivityThread.main(ActivityThread.java:4627)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at java.lang.reflect.Method.invokeNative(Native Method)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at java.lang.reflect.Method.invoke(Method.java:521)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at dalvik.system.NativeStart.main(Native Method)
  05-31 17:53:19.730: E/AndroidRuntime(1958): Caused by: java.lang.NullPointerException
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at android.app.Activity.findViewById\untime(1958):  at java.lang.Class.newInstanceImpl(Native Method)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at java.lang.Class.newInstance(Class.java:1429)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
  05-31 17:53:19.730: E/AndroidRuntime(1958):     ... 11 more
  </code></pre>