title: Getting NullPointerException trying to use Volley singleton
body: <p>Main Activity Class
  Hello guys I am tryin to parse data and I get a java.lang. null exception at return sSingleton.getApplicationContext(); Therefore, can you please help me?</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  
  private VolleySingleton mVolleySingleton;
  private RequestQueue mRequestQueue;
  private ArrayList&lt;ParseMe&gt; listblogs = new ArrayList&lt;&gt;();
  private static final String URL_GET="bestUrl";
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      final TextView ChangeMe = (TextView) findViewById(R.id.ChangeMeTextView);
      Button SunnyButton = (Button) findViewById(R.id.SunnyButton);
      Button FoggyButton = (Button) findViewById(R.id.FoggyButton);
      setSupportActionBar(toolbar);
  
      mVolleySingleton = VolleySingleton.getInstance();
      mRequestQueue = mVolleySingleton.getRequestQueue();
      JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, URL_GET, (String) null, new Response.Listener&lt;JSONObject&gt;() {
          @Override
          public void onResponse(JSONObject response) {
              ToastTest.m(this.toString());
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              error.printStackTrace();
          }
      });
      mRequestQueue.add(request);
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I also set up a singleton, with a singleton application and a volleysingleton</p>
  
  <pre><code>import android.app.Application;
  </code></pre>
  
  <p>import android.content.Context;</p>
  
  <pre><code>public class MyApplicationSingleton extends Application{
  private static MyApplicationSingleton sSingleton;
  @Override
  public void onCreate() {
      super.onCreate();
      sSingleton=this;
  }
  public static MyApplicationSingleton getSingleton(){
      return sSingleton;
  }
  public static Context getAppContext(){
      return sSingleton.getApplicationContext();
  }
  </code></pre>
  
  <p>}
  VolleySingleton Class</p>
  
  <pre><code> public class VolleySingleton {
  private static VolleySingleton sSingleton=  null;
  private RequestQueue mRequestQueue;
  private ImageLoader mImageLoader;
  
  private VolleySingleton() {
  
      mRequestQueue = Volley.newRequestQueue(MyApplicationSingleton.getAppContext());
      mImageLoader = new ImageLoader(mRequestQueue, new ImageLoader.ImageCache() {
  
          private LruCache&lt;String, Bitmap&gt; cache = new LruCache&lt;&gt;((int) Runtime.getRuntime().maxMemory() / 1024 / 8);
  
          @Override
          public Bitmap getBitmap(String url) {
  
              return cache.get(url);
          }
  
          @Override
          public void putBitmap(String url, Bitmap bitmap) {
              cache.put(url, bitmap);
  
          }
      });
  
  }
  
  //if our object is equal to null we are going to want to create a new instance of it
  public static VolleySingleton getInstance() {
      if (sSingleton == null) {
          sSingleton = new VolleySingleton();
      }
      return sSingleton;
  }
  
  public RequestQueue getRequestQueue() {
      return mRequestQueue;
  }
  
  public ImageLoader getImageLoader() {
      return mImageLoader;
  }
  </code></pre>
  
  <p>}</p>