title: startActivity(intent) is not opening activity
body: <p>I'm making an android app with 2 activities and a Java class that reads/writes RFID data using NFC. </p>
  
  <p>I'm using the <code>enableReaderMode()</code> method to enable reader/writer mode in the <code>mainActivity</code>, which then calls <code>onTagDiscovered</code> in a separate java class. Once in the <code>onTagDiscovered</code> method, I'm calling <code>mainActivity.startNewActivity()</code> to open a the second activity. I know that I'm reaching <code>startNewActivity()</code> because of a log message, but the activity is not actually starting. The app doesn't crash, and I'm not getting any errors, it just isn't starting. I've tried placing a button in the <code>mainActivity</code> and opening that way, and it works fine. It just doesn't work when I call the method from encode.java. </p>
  
  <p>**I know that it is not necessary to open the activity from Encode.java, and that I could directly code this into MainActivity, but I'm preparing to do something more complex where I will need to open from Encode.java, and I want to test that the activity will open at all. </p>
  
  <p>Here's the code</p>
  
  <p>Encode.java</p>
  
  <pre><code>public class Encode implements NfcAdapter.ReaderCallback {
      MainActivity mainActivity = new MainActivity(); 
  
      public void onTagDiscovered(Tag tag) {
          Log.i(TAG, "New tag discovered"); 
          mainActivity.startNewActivity(); 
      }
  </code></pre>
  
  <p>MainActivity</p>
  
  <pre><code> public void startNewActivity() {
      Log.v(TAG, "in startNewActivity");
      Intent intent = new Intent(this, Success.class);
      startActivity(intent);
  }
  </code></pre>
  
  <p>AndroidManifest.xml</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.project" &gt;
  
      &lt;uses-sdk android:minSdkVersion="10" /&gt;
      &lt;uses-permission android:name="android.permission.NFC"/&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-feature android:name="android.hardware.nfc" android:required="true" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/xband"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
  
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name" &gt;
  
              &lt;intent-filter&gt;
                  &lt;action android:name="android.nfc.action.NDEF_DISCOVERED" /&gt;
                  &lt;action android:name="android.nfc.action.TECH_DISCOVERED" /&gt;
                  &lt;action android:name="android.nfc.action.TAG_DISCOVERED" /&gt;
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&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;meta-data android:name="android.nfc.action.TECH_DISCOVERED"
                  android:resource="@xml/nfc_tech" /&gt;
  
          &lt;/activity&gt;
          &lt;activity android:name=".Success" &gt;
  
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Success.java</p>
  
  <pre><code>package com.project;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.util.Log;
  
  public class Success extends Activity {
      private static final String TAG = "encode";
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.success_activity);
          Log.v(TAG, "in success activity");
      }
  
  
  }
  </code></pre>
  
  <p>I tried adding the following code and then got this error message: 
  Encode.java</p>
  
  <pre><code>public void onTagDiscovered(Tag tag) {
          Log.i(TAG, "New Tag Discovered");
          Handler handler = new Handler(Looper.getMainLooper());
          handler.post(new Runnable() {
             @Override
              public void run() {
                 mainActivity.startNewActivity();
             }
          });
  }
  </code></pre>
  
  <p><br> </p>
  
  <pre><code>02-20 11:52:27.739  22088-22088/com.project E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: com.project, PID: 22088
      java.lang.NullPointerException
              at android.app.Activity.startActivityForResult(Activity.java:3474)
              at android.app.Activity.startActivityForResult(Activity.java:3435)
              at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
              at android.app.Activity.startActivity(Activity.java:3677)
              at android.app.Activity.startActivity(Activity.java:3645)
              at com.project.MainActivity.startNewActivity(MainActivity.java:110)
              at com.project.encoding.Encode$1.run(Encode.java:331)
              at android.os.Handler.handleCallback(Handler.java:733)
              at android.os.Handler.dispatchMessage(Handler.java:95)
              at android.os.Looper.loop(Looper.java:157)
              at android.app.ActivityThread.main(ActivityThread.java:5293)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
  </code></pre>