I\'m writing an app that notifies a user of very time sensitive information, and I think a lot of them would want to use a phone ringtone instead of just the short notification
This should do it.
.... mediaPlayer.start(); .... final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { if (mediaPlayer.isPlaying()) mediaPlayer.stop(); } }, timeout);