title: Can't create handler inside thread that has not called Looper.prepare() Android Media Player
body: <p>Am just trying to play music via Media Player for n secs.</p>
  
  <pre><code>public void playMusic(String music_path) {
      MediaPlayer mMediaPlayer = new MediaPlayer();
  
      try {
          mMediaPlayer.setDataSource(music_path);
          mMediaPlayer.prepare();
          mMediaPlayer.start();
          new Handler().postDelayed(new Runnable() {
              @Override
              public void run() {
                  mMediaPlayer.stop();
              }
          }, 20000);
          mMediaPlayer.release();
          Log.i(TAG, "Done Playing");
      } catch (IOException e) {
          e.printStackTrace();
      }
      return;
  }
  </code></pre>
  
  <p>My Function Caller from main file:</p>
  
  <pre><code>public void Play_Music() {
          mBtTestUtils.playMusic(MUSIC_PATH);
      }
  }
  </code></pre>
  
  <p>Here when i do this i get the following error :</p>
  
  <pre><code>java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
  </code></pre>
  
  <p>Any help would be appreciated.</p>