Error: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference : <p>Getting Null Point Exception on when I try to change <code>TextView</code> text to putExtra string from an <code>Intent</code>.</p>

<p>Here's my code:</p>

<p>activity.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".Login"&gt;


    &lt;TextView
            android:text="TextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/receive"
            android:textSize="10sp"
    /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>activity1.kt</p>

<pre><code>class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

    fun begin(view: View){
        val intent = Intent(this, Login::class.java)
        intent.putExtra("Key", "Value")

        startActivity(intent)
    }
}
</code></pre>

<p>activity2.kt</p>

<pre><code>class Login : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {

        val s: String = intent.getStringExtra("Key")
        println(s)

        val textView = findViewById&lt;TextView&gt;(R.id.receive).apply {
            text = s
        }

        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_login)
    }
}
</code></pre>

<p>Any idea what the problem is?</p>
