Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Application crash on Start (Opening intent on Button)
    primarykey
    data
    text
    <p>I am trying to open another activity through Intent on Button press. But the <strong>app crashes every time</strong> on launch.</p> <p><strong>IntentTest.java:</strong></p> <pre><code>package com.example.intenttest; public class IntentTest extends Activity { Button b1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_intent_test); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent2 = new Intent(IntentTest.this, IntentTest2.class); startActivity(intent2); } }); } } </code></pre> <p><strong>IntentTest2.java:</strong></p> <pre><code>package com.example.intenttest; public class IntentTest2 extends Activity { TextView textView1; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_intent_test2); textView1=(TextView)findViewById(R.id.textView1); } } </code></pre> <p><strong>Manifest:</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.example.intenttest" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="11" android:targetSdkVersion="17" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.intenttest.IntentTest" 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:label="@string/app_name" android:name="com.example.intenttest.IntentTest2" /&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Here is the <strong>LogCat</strong> where the app crashes:</p> <pre><code>12-18 11:59:59.563: W/Trace(20985): error opening trace file: No such file or directory (2) 12-18 11:59:59.623: D/AndroidRuntime(20985): Shutting down VM 12-18 11:59:59.623: W/dalvikvm(20985): threadid=1: thread exiting with uncaught exception (group=0x40c8d930) 12-18 11:59:59.633: E/AndroidRuntime(20985): FATAL EXCEPTION: main 12-18 11:59:59.633: E/AndroidRuntime(20985): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.intenttest/com.example.intenttest.IntentTest}: java.lang.NullPointerException </code></pre> <p>I cant find out what is wrong. Please help. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload