title: Why my starting Activity is not working?
body: <p>First I want to say is that I am new to Android. I want to start my <code>Activity</code> from an <code>AsyncTask</code>, but I don't know why I am getting an error.</p>
  
  <pre><code>@Override
  protected void onPostExecute(String string) {
      // Now we have your JSONObject, play around with it.
  
      //MainActivity.t.setText(string);
  
      MainActivity.mainActivity.startPlataform();
  }
  </code></pre>
  
  <p>This is my <code>onPostExecute()</code> when everything works and I am accessing from a static <code>MainActivity</code> variable, but I don't know another way to do it.</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      public static MainActivity mainActivity;
      public Intent detailIntent;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mainActivity = new MainActivity();
          detailIntent = new Intent(this, Main_Plataform.class);
      }
  
      ...
  
      public void startPlataform() {
          try {
              startActivity(detailIntent);
          } catch (Exception e) {
              Log.e("Fehler!", "Error why ???" + e.toString());
          }
      }
  }
  </code></pre>
  
  <p>When I call the <code>startPlataform()</code> method with a <code>Button</code> in my <code>MainActivity</code> it works fine 
  but it does not in `the onPostExecute(). I think something about the static variable is wrong.</p>
  
  <p>Here is my logcat:</p>
  
  <pre><code>05-03 20:41:37.403: E/AndroidRuntime(1562): FATAL EXCEPTION: main
  05-03 20:41:37.403: E/AndroidRuntime(1562): Process: com.example.patronusgps, PID: 1562
  05-03 20:41:37.403: E/AndroidRuntime(1562): java.lang.NullPointerException
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  android.app.Activity.startActivityForResult(Activity.java:3424)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  android.app.Activity.startActivityForResult(Activity.java:3385)    
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  android.app.Activity.startActivity(Activity.java:3627)    
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  android.app.Activity.startActivity(Activity.java:3595)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  com.example.patronusgps.MainActivity.startPlataform(MainActivity.java:72)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  com.example.patronusgps.JSONParser.onPostExecute(JSONParser.java:106)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  com.example.patronusgps.JSONParser.onPostExecute(JSONParser.java:1)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  android.os.AsyncTask.finish(AsyncTask.java:632)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  android.os.AsyncTask.access$600(AsyncTask.java:177)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  android.os.Handler.dispatchMessage(Handler.java:102)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  android.os.Looper.loop(Looper.java:136)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  android.app.ActivityThread.main(ActivityThread.java:5017)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  java.lang.reflect.Method.invokeNative(Native Method)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  java.lang.reflect.Method.invoke(Method.java:515)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  05-03 20:41:37.403: E/AndroidRuntime(1562):     at
  dalvik.system.NativeStart.main(Native Method)
  </code></pre>