title: How to correctly start activity from PostExecute in Android?
body: <p>I have an AsyncTask, that fills a custom List with parsed data from Internet. </p>
  
  <p>In PostExecute I fill that List and get it ready to transfer it to a new Activity. </p>
  
  <p>I do it this way:</p>
  
  <pre><code>@Override
  protected void onPostExecute(List&lt;VideoDataDescription&gt; result) 
  {
      super.onPostExecute(result);
      MainActivity.progressDialog.dismiss();
  
      context.startActivity(new Intent(context, ResultsQueryActivity.class));
  
  
  }
  </code></pre>
  
  <p>where context</p>
  
  <pre><code>    private Context context;
  </code></pre>
  
  <p>In LogCat after executing this code I get a Java.lang.NullPointerException.
  Is this possible and correct to start an Activity as I do it?</p>
  
  <p><strong>UPD</strong>
  I have added</p>
  
  <pre><code>    private Context mContext;
  
  
  public YoutubeAndYahooParser(Context context) 
  {
      super();
      this.mContext = context;
  }
  </code></pre>
  
  <p>to initialize context and call </p>
  
  <pre><code>YoutubeAndYahooParser youtubeAndYahooParser = new YoutubeAndYahooParser(ResultsQueryActivity.this);
                      youtubeAndYahooParser.execute("my string to pass in asynctak");
  </code></pre>
  
  <p>After this in PostExecute</p>
  
  <pre><code>Intent intent = new Intent(mContext, ResultsQueryActivity.class);
   intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   mContext.startActivity(intent);    
  </code></pre>
  
  <p>I added new flag because of I have got in LogCat the next:</p>
  
  <p>*Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?*</p>
  
  <p>Am I right?</p>