title: Null pointer exception when calling method from a different class
body: <p>When I attempt to call the method <code>loadUserList()</code> from another class, I get the following error:</p>
  
  <pre><code>Attempt to invoke virtual method android.content.res.Resources 
  android.content.Context.getResources() on a null object reference
  </code></pre>
  
  <p><strong>This is my loadUserList method</strong></p>
  
  <pre><code>public void loadUserList()
  {
      final ProgressDialog dia = ProgressDialog.show(this, null, getString(R.string.alert_loading));
  
      ParseQuery&lt;ParseObject&gt; query = ParseQuery.getQuery("Chat_User");
      query.whereEqualTo("receiver", ParseUser.getCurrentUser());
      query.include("sender");
  
      query.findInBackground(new FindCallback&lt;ParseObject&gt;()
      {
  
          @Override
          public void done(List&lt;ParseObject&gt; li, ParseException e)
          {
              dia.dismiss();
  
              if (li != null)
              {
                  if (li.size() == 0)
                      Toast.makeText(com.yarnyard.UserList.this, R.string.msg_no_user_found,
                              Toast.LENGTH_SHORT).show();
  
                  uList = new ArrayList&lt;ParseObject&gt;(li);
                  ListView list = (ListView) findViewById(R.id.list);
                  list.setAdapter(new UserAdapter());
                  list.setOnItemClickListener(new OnItemClickListener()
                  {
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int pos, long arg3)
                      {
                          loadUserList();
                          /*startActivity(new Intent(com.yarnyard.UserList.this, Chat.class)
                                  .putExtra(Const.EXTRA_DATA, uList.get(pos).getUsername()));*/
                      }
                  });
              }
              else
              {
                  Utils.showDialog(
                          com.yarnyard.UserList.this,
                          getString(R.string.err_users) + " "
                                  + e.getMessage());
                  e.printStackTrace();
              }
          }
      });
  }
  </code></pre>
  
  <p><strong>This is how I am calling it</strong></p>
  
  <pre><code>public void done(ParseException e)
  {
      UserList UserList = new UserList();
      UserList.loadUserList();
  }
  </code></pre>
  
  <p><strong>My error log</strong></p>
  
  <pre><code>07-30 14:14:56.219  13383-13383/com.anonimv2 E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: com.anonimv2, PID: 13383
  java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
          at android.content.ContextWrapper.getResources(ContextWrapper.java:85)
          at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:74)
          at android.content.Context.getString(Context.java:376)
          at com.yarnyard.UserList.loadUserList(UserList.java:96)
          at com.yarnyard.custom.CustomActivity.onOptionsItemSelected(CustomActivity.java:116)
          at android.app.Activity.onMenuItemSelected(Activity.java:2882)
          at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:353)
          at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1131)
          at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:761)
          at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
          at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:904)
          at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:894)
          at android.widget.ActionMenuView.invokeItem(ActionMenuView.java:587)
          at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:141)
          at android.view.View.performClick(View.java:4832)
          at android.view.View$PerformClick.run(View.java:19839)
          at android.os.Handler.handleCallback(Handler.java:739)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:211)
          at android.app.ActivityThread.main(ActivityThread.java:5321)
          at java.lang.reflect.Method.invoke(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:372)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)
  </code></pre>
  
  <p>Any advice would be much appreciated.</p>