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;
import android.widget.TextView;

public class ringtone extends Activity
{
	
	 Ringtone ringtone;
	 private Button btn_stop;
	 TextView tv_titre;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ringtone_layout);
		
		
		Bundle extras = getIntent().getExtras();
		String titre = extras.getString("titre");
		
		tv_titre = (TextView) findViewById(R.id.tv_titre);
        btn_stop = (Button) findViewById(R.id.btn_stop);

        
        tv_titre.setText(titre);
        
        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();
            	finish();
            }
        });
		
		
		
		
	}	


}
