title: method invocation may produce java.lang.nullpointerexception
body: <p>When I try to run this, the emulator crashes and I get this Exception </p>
  
  <blockquote>
    <p>method invocation may produce java.lang.nullpointerexception</p>
  </blockquote>
  
  <p>Here is my code, I know the error is in the last line but I don't know how to fix it</p>
  
  <pre><code>import android.os.StrictMode;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.TextView;
  import java.net.MalformedURLException;
  public class MainActivity extends AppCompatActivity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  
          StrictMode.setThreadPolicy(policy);
  
          // FIXME: Experimenting
  
          try {
  
              ReadingFactory parser = new BOMFactory();
              WeatherService s = new WeatherService(
                      "BOM", "http://www.bom.gov.au/fwo/IDV60801/IDV60801.94839.json", parser
              );
  
              s.run();
  
           //   Thread test = new Thread(s);
             // test.start();
  
          } catch (MalformedURLException e) {
              e.printStackTrace();
          }
  
          BOMResponse bomResponse = new BOMResponse();
          TextView temperature  = (TextView)findViewById(R.id.temperature);
          temperature.setText(String.format("%d", bomResponse.getObservations().getData().get(0).getAirTemp().toString()));
  
      }
  }
  </code></pre>
  
  <p>Here is my complete Stacktrace</p>
  
  <pre><code>FATAL EXCEPTION: main                                                                    
  Process: com.example.teamredrmit.weatherapp, PID: 1792                                                                   
  java.lang.RuntimeException: Unable to start activity
  ComponentInfo{com.example.teamredrmit.weatherapp/com.example.teamredrmit.weathe
  app.MainActivity}: java.lang.NullPointerException                                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)             at android.app.ActivityThread.access$800(ActivityThread.java:135)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:136)
  at android.app.ActivityThread.main(ActivityThread.java:5001)
  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:785)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
  at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.NullPointerException
  at     com.example.teamredrmit.weatherapp.MainActivity.onCreate(MainActivity.java:41)
  at android.app.Activity.performCreate(Activity.java:5231)
  at     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
  at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
  at     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 
  at android.app.ActivityThread.access$800(ActivityThread.java:135) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
  at android.os.Handler.dispatchMessage(Handler.java:102) 
  at android.os.Looper.loop(Looper.java:136) 
  at android.app.ActivityThread.main(ActivityThread.java:5001) 
  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:785) 
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>