title: MediaPlayer start()/stop() mUri is null
body: <p>I have an activity that looks like,</p>
  
  <pre><code>public class TestActivity extends Activity {
  
      private SensorManager      mSensorManager;
          private ShakeEventListener mSensorListener;
      private MediaPlayer        mPlayer;
  
      private boolean            mIsPlaying; 
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          requestWindowFeature(Window.FEATURE_NO_TITLE); 
  
          this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  
          setContentView(R.layout.testsound);
  
          mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
          mSensorListener = new ShakeEventListener();   
          mSensorListener.setOnShakeListener(new ShakeEventListener.OnShakeListener() {
  
            @Override 
            public void onShake() {
              toggleSound();
            }
          });  
      }
  
      @Override
      protected void onResume() {
        super.onResume();
        mSensorManager.registerListener(mSensorListener,
            mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
            SensorManager.SENSOR_DELAY_UI);
      }
  
      @Override
      protected void onPause() {
        super.onPause();
        mSensorManager.unregisterListener(mSensorListener);
        stopSound();
      }    
  
      protected void toggleSound() {
          if (!mIsPlaying) {
            startSound();
          } else {
            stopSound();  
          }
      }
  
  
      protected void startSound() {
  
          if (mPlayer == null)
            {
              mPlayer = MediaPlayer.create(TestActivity.this, R.raw.test);
              mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 
  
              mPlayer.setLooping(true);
              mPlayer.start();  
  
              mPlayer.setOnCompletionListener(new OnCompletionListener() {
  
                   @Override
                  public void onCompletion(MediaPlayer mp) {
                    stopSound();
                  }
              }); 
  
              mIsPlaying = true;
            }
      }
  
  
      protected void stopSound() {
          if (mPlayer != null) {
                if (mPlayer.isPlaying())
                {
                    mPlayer.stop();
                }
                mPlayer.release();
                mPlayer = null;
          }
  
          mIsPlaying = false;
      }
  
  }
  </code></pre>
  
  <p>I know this may not be the best way to do it, but I'm just starting out with some random tests. I haven't included the ShakeEventListener, but that pretty much just detects a shake event, upon which a sample sound is played in loop (yes, it's quite annoying!) until the next shake.</p>
  
  <p>This does in fact work really well, except I get LogCat entries with tag MediaPlayer that say <code>start() mUri is null</code> or <code>stop() mUri is null</code> when the start and stop commands are executed. This makes me believe I do something wrong, but I can't find out what it is, nor is this apparently a popular error, when I google around a bit.</p>
  
  <p>Would anyone have an idea what it means here? Sorry if I'm being thick - it's all still a bit confusing to me.</p>
  
  <p>UPDATE (from comments): One thing I did was give it an actual Uri (built from path), and then it comes with a similar warning, now saying <code>start() mUri is android.resource://com.joris.soundtest/2130968576</code> (level D), preceded this time by an E-level <code>Uri is android.resource//...</code> (dots give same uri). Is it possible that those LogCat entries are just 'informative', for debugging? The E-level one wouldn't sound like it ..</p>
  
  <p>Thanks!
  -Joris.</p>