title: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference
body: <p>I am getting two type of responses from the server the first one in case of the <code>routes</code> is being sent to the server with the JSOn string then I get as response <code>{"status":230,"routes":[1,9,3]}</code> or not being sent then I get <code>{"status":201}</code>. Currently the app crashes if the response is <code>{"status":201}</code> and I am getting:</p>
  
  <blockquote>
    <p>Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference</p>
  </blockquote>
  
  <p>How can I prevent that? I want to do nothing if that the server response?</p>
  
  <pre><code>            Gson gson = new Gson();
              StopsJSON data = gson.fromJson(sb.toString(), StopsJSON.class);
  
              routes = data.getRoutes();
  
  @Override
      protected void onPostExecute(Void result) {
          // Intent with Conetxt of the Asyntask class and
          Intent intent = new Intent(mContext, MainActivity.class);
          intent.putIntegerArrayListExtra("stop_route", routes);
          intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
          mContext.startActivity(intent);
  
      }
  </code></pre>
  
  <p>In MainActivity:</p>
  
  <pre><code>@Override
      protected void onNewIntent(Intent intent) {
          // TODO Auto-generated method stub
          super.onNewIntent(intent);
  
          // getIntent() should always return the most recent
          setIntent(intent);
  
          Bundle extras = getIntent().getExtras();
          if (extras != null &amp;&amp; extras.containsKey("stop_route")) {
  
              final ArrayList&lt;Integer&gt; routeList = extras
                      .getIntegerArrayList("stop_route");
              int routeListSize = routeList.size();
              if(routeListSize &gt; 0){
  
  
      }
  }
  </code></pre>