Ringtone to ring for few seconds and stop
<p>I have the following code which would give me a ringtone from my activity. I need this ringtone to keep ringing continuously for 30 seconds. As you can observe from the code below, I stop this ringtone on the 30th second using Timer. The issue I have is, instead of ringing continuously for 30 seconds, it rings for once and then stops. Can someone point out the solution for this such that I can have the ringtone for 30 seconds continuous?</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
    final Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
    r.play();
    final Timer t = new Timer();
    t.schedule(new TimerTask() {
        public void run() {
            r.stop();
            t.cancel();
            finish();
        }
    }, 30000);

}
</code></pre>
