title: App Crash when i click button to change activity
body: <p>I'm sorry if i'm not so accurate but this is my first app.</p>
  
  <p>The problem is: when i press a <strong>button</strong> to <strong>change activity</strong> the app crash.</p>
  
  <p>Can someone help me? <strong><em>Thanks for all!!</em></strong></p>
  
  <p>If you wanna have more information tell me and I try to explain better.</p>
  
  <hr>
  
  <p>CODE:</p>
  
  <p>MAIN ACTIVITY</p>
  
  <pre><code>    package com.example.principale.designazioni;
  
      import android.content.Intent;
      import android.support.v7.app.AppCompatActivity;
      import android.os.Bundle;
      import android.view.View;
      import android.widget.Button;
  
      public class MainActivity extends AppCompatActivity {
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
  
              Button invia = (Button) findViewById(R.id.buttInvia);
              invia.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      openActivityPage1();
                  }
              });
  
  
          }
  
          public void openActivityPage1() {
              Intent intent = new Intent (getApplicationContext(), Page1.class);
              startActivity(intent);
          }
      }
  </code></pre>
  
  <p>XML MAIN ACTIVITY</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"
      tools:layout_editor_absoluteY="73dp"&gt;
  
      &lt;ImageView
          android:id="@+id/imageView4"
          android:layout_width="231dp"
          android:layout_height="229dp"
          android:layout_marginEnd="8dp"
          android:adjustViewBounds="false"
          android:contentDescription='@string tools:ignore="ContentDescription"'
          android:cropToPadding="false"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.146"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.04"
          app:srcCompat="@mipmap/logo_grigio" /&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="272dp"
          android:layout_height="51dp"
          android:fontFamily="monospace"
          android:text="Disponibilità"
          android:textAlignment="center"
          android:textColor="@android:color/holo_orange_dark"
          android:textSize="30sp"
          android:textStyle="bold"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.818"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/imageView4"
          app:layout_constraintVertical_bias="0.093" /&gt;
  
      &lt;Button
          android:id="@+id/buttInvia"
          style="@style/Widget.AppCompat.Button.Borderless"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:fontFamily="monospace"
          android:text="Invia"
          android:textAlignment="center"
          android:textAllCaps="true"
          android:textColor="@android:color/holo_orange_dark"
          android:textSize="36sp"
          android:textStyle="bold"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.502"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/textView2"
          app:layout_constraintVertical_bias="0.482" /&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>ACTIVITY PAGE1</p>
  
  <pre><code>package com.example.principale.designazioni;
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  
  public class Page1 extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_page1);
  
          EditText mail = (EditText) findViewById(R.id.editTextMail);
          EditText nome = (EditText) findViewById(R.id.editTextNome);
          EditText cognome = (EditText) findViewById(R.id.editTextCognome);
          EditText tessera = (EditText) findViewById(R.id.editTextTessera);
  
          Button avanti = (Button) findViewById(R.id.buttInvia);
  
          Bundle bundle = new Bundle();
          bundle.putString("mail", mail.getText().toString());
          bundle.putString("nome", nome.getText().toString());
          bundle.putString("cognome", cognome.getText().toString());
          bundle.putString("tessera", tessera.getText().toString());
  
          avanti.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  openActivityPage2();
              }
          });
      }
  
      public void openActivityPage2() {
          Intent intent = new Intent (getApplicationContext(), Page2.class);
          startActivity(intent);
      }
  }
  </code></pre>
  
  <p>XML ACTIVITY PAGE1</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".Page1"&gt;
  
      &lt;TextView
          android:id="@+id/textView3"
          android:layout_width="71dp"
          android:layout_height="27dp"
          android:fontFamily="monospace"
          android:text="E-Mail"
          android:textAlignment="textStart"
          android:textColor="@android:color/holo_orange_dark"
          android:textSize="18sp"
          android:textStyle="bold"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.093"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.06" /&gt;
  
      &lt;TextView
          android:id="@+id/textView4"
          android:layout_width="96dp"
          android:layout_height="27dp"
          android:fontFamily="monospace"
          android:text="Cognome"
          android:textAlignment="textStart"
          android:textColor="@android:color/holo_orange_dark"
          android:textSize="18sp"
          android:textStyle="bold"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.102"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.44" /&gt;
  
      &lt;TextView
          android:id="@+id/textView6"
          android:layout_width="71dp"
          android:layout_height="27dp"
          android:fontFamily="monospace"
          android:text="Numero di Tessera"
          android:textAlignment="textStart"
          android:textColor="@android:color/holo_orange_dark"
          android:textSize="18sp"
          android:textStyle="bold"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.093"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.629" /&gt;
  
      &lt;TextView
          android:id="@+id/textView5"
          android:layout_width="71dp"
          android:layout_height="27dp"
          android:fontFamily="monospace"
          android:text="Nome"
          android:textAlignment="textStart"
          android:textColor="@android:color/holo_orange_dark"
          android:textSize="18sp"
          android:textStyle="bold"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.093"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.251" /&gt;
  
      &lt;EditText
          android:id="@+id/editTextMail"
          android:layout_width="306dp"
          android:layout_height="50dp"
          android:ems="10"
          android:fontFamily="monospace"
          android:inputType="textEmailAddress"
          android:textColor="@android:color/background_light"
          android:textSize="18sp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/textView3"
          app:layout_constraintVertical_bias="0.0" /&gt;
  
      &lt;EditText
          android:id="@+id/editTextCognome"
          android:layout_width="306dp"
          android:layout_height="50dp"
          android:ems="10"
          android:inputType="textPersonName"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/editTextNome"
          app:layout_constraintVertical_bias="0.17" /&gt;
  
      &lt;EditText
          android:id="@+id/editTextNome"
          android:layout_width="306dp"
          android:layout_height="50dp"
          android:ems="10"
          android:inputType="textPersonName"
          app:layout_constraintBottom_toTopOf="@+id/textView4"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/textView5"
          app:layout_constraintVertical_bias="0.0" /&gt;
  
      &lt;EditText
          android:id="@+id/editTextTessera"
          android:layout_width="306dp"
          android:layout_height="50dp"
          android:ems="10"
          android:inputType="number"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/textView6"
          app:layout_constraintVertical_bias="0.0" /&gt;
  
      &lt;Button
          android:id="@+id/button"
          style="@style/Widget.AppCompat.Button.Borderless"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:fontFamily="monospace"
          android:text="Avanti"
          android:textAlignment="center"
          android:textColor="@android:color/holo_orange_dark"
          android:textSize="36sp"
          android:textStyle="bold"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toBottomOf="@+id/editTextTessera"
          app:layout_constraintVertical_bias="0.487" /&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>ACTIVITY PAGE2</p>
  
  <pre><code>package com.example.principale.designazioni;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.TextView;
  
  public class Page2 extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_page2);
  
          final TextView nome = (TextView) findViewById(R.id.textViewPage2);
          Bundle bundle = this.getIntent().getExtras();
          nome.setText(bundle.getString("nome"));
      }
  }
  </code></pre>
  
  <p>XML ACTIVITY PAGE2</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".Page2"&gt;
  
      &lt;TextView
          android:id="@+id/textViewPage2"
          android:layout_width="180dp"
          android:layout_height="47dp"
          android:fontFamily="monospace"
          android:text="TextView"
          android:textAlignment="center"
          android:textColor="@android:color/holo_orange_dark"
          android:textSize="30sp"
          android:textStyle="bold"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.5"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>ANDROID 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.example.principale.designazioni"&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&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:name=".Page1" /&gt;
          &lt;activity android:name=".Page2"&gt;&lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>STACK TRACE</p>
  
  <pre><code>08-24 10:21:07.370 6819-6819/com.example.principale.designazioni E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.principale.designazioni, PID: 6819
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.principale.designazioni/com.example.principale.designazioni.Page1}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3194)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
          at android.app.ActivityThread.-wrap12(Unknown Source:0)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
          at android.os.Handler.dispatchMessage(Handler.java:108)
          at android.os.Looper.loop(Looper.java:166)
          at android.app.ActivityThread.main(ActivityThread.java:7425)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
       Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
          at com.example.principale.designazioni.Page1.onCreate(Page1.java:30)
          at android.app.Activity.performCreate(Activity.java:7372)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3147)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302) 
          at android.app.ActivityThread.-wrap12(Unknown Source:0) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891) 
          at android.os.Handler.dispatchMessage(Handler.java:108) 
          at android.os.Looper.loop(Looper.java:166) 
          at android.app.ActivityThread.main(ActivityThread.java:7425) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 
  </code></pre>