Question: I'm using a RingtoneManager with RingtonePreference. When I use the default Ringtone, there is no problem, but when i use a configured Ringtone, it's playing for minutes... I don't know if the song's duration is minutes or if it plays in a loop... 

here my code:

```
private static void playNotificationSound(Context context) {
    RingtoneManager rm  = new RingtoneManager(context);
    String ringtone = MySharedPreferences.ringtone(context);
    Uri uri = null;
    if(ringtone == null)
        uri = RingtoneManager
            .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    else
        uri = Uri.parse(ringtone);
    if (uri != null) {
        Ringtone rt = RingtoneManager.getRingtone(context, uri);
        if (rt != null) {
            rt.setStreamType(AudioManager.STREAM_NOTIFICATION);
            rt.play();
        }
    }
}

```

I use it to play a song with a notification and I don't want the phone to play for 5minutes...

Answer: 
Try adding the following Line.

```
ringtoneManager.stopPreviousRingtone();

```
Can you use thread like this?

```
if (rt != null) {
                rt.setStreamType(AudioManager.STREAM_NOTIFICATION);

                rt.play();
            }

            Thread myThread = new Thread() {

                int wait = 0;

                @Override
                public void run() {
                    try {
                        super.run();

                        while (wait < 5000) {
                            sleep(500);
                            wait += 500;
                        }
                    } catch (Exception e) {

                    } finally {
                        if (rt.isPlaying())
                            rt.stop();

                    }
                }
            };
            myThread.start();

```