title: trying Using Mediaplayer within a Fragment
body: <p>I'm a beginner of programming, and trying to use MediaPlayer in a Fragment,
  but have the same problem following:</p>
  
  <p><a href="https://stackoverflow.com/questions/13073471/using-mediaplayer-within-a-fragment/14440656#14440656">Using Mediaplayer within a Fragment</a></p>
  
  <p>this person seemed solve the problem so quickly, but I couldn't understand.
  please somebody help me</p>
  
  <p>What does it mean by "Use getActivity()" and "called after onAttach()"?<br>
  I put "getActivity()" in MediaPlayer.create() method like below:  </p>
  
  <pre><code>MediaPlayer mp = MediaPlayer.create( getActivity , resId ); 
  </code></pre>
  
  <p>Then compile error was disappeared but I got error when I try to turn on the 
  application on a device.  What should I do?  </p>
  
  <p>Does the Class have to extends Activity, Though I want to use Fragment class ?<br>
  Does the Class have to have internal class which extends fragment??<br>
  I'm confusing.</p>
  
  <p>I found the following URL...<br>
  <a href="http://developer.android.com/guide/components/fragments.html" rel="nofollow noreferrer">http://developer.android.com/guide/components/fragments.html</a> How do I add a Fragment to an Activity with a programmatically created content view</p>