title: nullpointerexception when trying to reach activity
body: <p>I am getting nullpointerexception when trying to reach my activity and change some ints.
  This is what it looks like:
  <em>MainActivity.java</em></p>
  
  <pre><code>    public class MainActivity extends Activity {
  
      public static SoundManager mSoundManager = new SoundManager();
  
      private static final String TAG = MainActivity.class.getSimpleName();
  
  
       private MainGamePanel gamePanel;
       SharedPreferences myPrefs;
  
       public int win = 0;
       public int fail = 0;
  
       int wins = 0;
       int fails = 0;
  
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      // requesting to turn the title OFF
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      // making it full screen
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
      // set our MainGamePanel as the View
      setContentView(new MainGamePanel(this));
  
      myPrefs = this.getSharedPreferences("hgbdata", 0);
  
          try {
          wins = myPrefs.getInt("wins", 0);
          fails = myPrefs.getInt("fails", 0);
          if ((wins != 0) &amp;&amp; (fails != 0)) {
          gamePanel.winn = wins;
          gamePanel.failn = fails;
          }
          } catch (NullPointerException npe) {
              Log.d(TAG, "Nothing to load");
          }
  
      //INIT SOUND
      mSoundManager.initSounds(getBaseContext());
      //SOUNDS
      mSoundManager.addSound(1, R.raw.draw);
      mSoundManager.addSound(2, R.raw.cheer);
      mSoundManager.addSound(3, R.raw.boo);
  
      }
  
  . . .
  
  
  public void win() {
      win++;
  }
  
  public void fail() {
      fail++;
  }
  
  
  
  }
  </code></pre>
  
  <p>This is where I am trying to reach the activity from:
  <em>MainGamePanel.java</em></p>
  
  <pre><code>public class MainGamePanel extends SurfaceView implements
  SurfaceHolder.Callback {
  
  private static final String TAG = MainGamePanel.class.getSimpleName();
  
  private MainThread thread;
  private MainActivity activity;
  
  . . .
  
  public void update() {
  
  //somewhere inside the update()
  activity.win();
  
  . . .
  
  activity.fail();
  
  }
  
  }
  </code></pre>
  
  <p>This is the log:</p>
  
  <pre><code>11-18 10:23:47.336: D/MainThread(1190): Starting game loop
  11-18 10:23:47.336: D/MainThread.initTimingElements()(1190): Timing elements for stats initialised
  11-18 10:23:47.386: D/gralloc_goldfish(1190): Emulator without GPU emulation detected.
  11-18 10:24:19.925: D/dalvikvm(1190): GC_CONCURRENT freed 356K, 2% free 28540K/28999K, paused 132ms+30ms, total 441ms
  11-18 10:24:20.965: W/dalvikvm(1190): threadid=13: thread exiting with uncaught exception (group=0x40a13300)
  11-18 10:24:20.965: E/AndroidRuntime(1190): FATAL EXCEPTION: Thread-105
  11-18 10:24:20.965: E/AndroidRuntime(1190): java.lang.NullPointerException
  11-18 10:24:20.965: E/AndroidRuntime(1190):     at com.nti.hanga.gubbe.MainGamePanel.update(MainGamePanel.java:591)
  11-18 10:24:20.965: E/AndroidRuntime(1190):     at com.nti.hanga.gubbe.MainThread.run(MainThread.java:92)
  11-18 10:24:21.235: I/AndroidRuntime(1190): VM exiting with result code 0, cleanup skipped.
  </code></pre>
  
  <p><code>MainGamePanel.java:591</code> is <code>activity.win();</code></p>
  
  <p>Thank you for your help.</p>