package com.androidbegin.buttonclicktutorial;

import android.app.Activity;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ringtone extends Activity
{
	
	 Ringtone ringtone;
	 private Button btn_stop;

	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ringtone_layout);
		
		
        btn_stop = (Button) findViewById(R.id.btn_stop);

        Uri alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
        if (alarmUri == null)
        {
            alarmUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        }
        
        ringtone = RingtoneManager.getRingtone(ringtone.this, alarmUri);
        ringtone.play();
        
        btn_stop.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v) 
            {
               // Ringtone ringtone = RingtoneManager.getRingtone(datepicker.this, alarmUri);
            	ringtone.stop();
            }
        });
		
		
		
		
	}	


}
