title: Which Context to use with MediaPlayer.create() in android?
body: <p>Which context i should use with <code>MediaPlayer.create()</code> ?</p>
  
  <p>I am using <code>Activity.this</code> with all my <code>MediaPlayer</code> objects. But i think it is giving me null pointer exception.</p>
  
  <p><em>Can context be a reason for force close in android or anything else ?</em></p>
  
  <p>Here "<code>com.bhavin.panara.kbc</code>" is package name.
  And 108th line is <code>mediaplayer.start()</code>.</p>
  
  <p>Here is code:</p>
  
  <pre><code>MediaPlayer mp;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      .
      .
      .
      mp = MediaPlayer.create(PlayScreen.this, R.raw.sound);
      .
      .
      mp.start(); // 108th line.
  
      }
  </code></pre>
  
  <p>Here is my log cat report.</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bhavin.panara.kbc/com.bhavin.panara.kbc.PlayScreen}: java.lang.NullPointerException
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1999)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2026)
  at android.app.ActivityThread.access$600(ActivityThread.java:127)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1174)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:4506)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
  at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.NullPointerException
  at com.bhavin.panara.kbc.PlayScreen.onCreate(PlayScreen.java:108)
  at android.app.Activity.performCreate(Activity.java:4479)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1963)
  ... 11 more
  </code></pre>