Am just trying to play music via Media Player for n secs.
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;
}
My Function Caller from main file:
public void Play_Music() {
        mBtTestUtils.playMusic(MUSIC_PATH);
    }
}
Here when i do this i get the following error :
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
Any help would be appreciated.
 
     
    