0

The app crashes when you click the button. There is a NullPointerException error, how can I fix that?

XML file of the crash button

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/clickaqui"
    android:id="@+id/registro"
    android:layout_below="@+id/textView"
    android:layout_centerHorizontal="true"
    android:onClick="onRegister"/>

AndroidManifest:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >
    <activity android:name=".CreateMessageActivity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".RegisterActvity"
        android:label="@string/app_name">
    </activity>
</application>

Code of the crash button:

Intent intent = new Intent(CreateMessageActivity.this,    RegisterActvity.class);
        startActivity(intent);

0 Answers0