package my.dungTime;


import java.util.Timer;
import java.util.TimerTask;


import android.app.Activity;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
 

public class dungTime extends Activity implements OnCheckedChangeListener {
    /** Called when the activity is first created. */

       int i;
      
   private static final int ID=1337;
   private Timer timer = new Timer();
  
      
      
    RadioGroup rg;
    TextView tv;
    Button btn;
    Button btn2;
    Button btn3;
   
   
      
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

       
        rg = (RadioGroup) findViewById(R.id.RadioGroup01);
        rg.setOnCheckedChangeListener(this);
        tv = (TextView) findViewById(R.id.TextView01);
        btn = (Button)findViewById(R.id.Button01);
        btn2 = (Button)findViewById(R.id.Button02);
        btn3 = (Button)findViewById(R.id.Button03);
       
       
    }
   
 
       @Override
       public void onCheckedChanged(RadioGroup group, int id) {
             // TODO Auto-generated method stub
             if(group == rg) {
                    if(id == R.id.min60)
                    {
                          i=6;
                    }
                    else if(id == R.id.min120)
                    {
                     i=12;
                    }
                    else if(id == R.id.min150)
                    {
                     i=15;
                    }
                    else if(id == R.id.cancel)
                    {
                     i=0;
                    }
             }
            
      
      
       btn.setOnClickListener(new OnClickListener() {
           public void onClick(View v) {
           
      
            TimerTask task = new TimerTask(){
             public void run(){
              notifyMe();
             }
            
            };
           
           
            timer.schedule(task, i*1000);
            Toast.makeText(dungTime.this, "알림 설정 되었습니다", 0).show();
              
        }        
       });
      
     
      
      
      
       btn3.setOnClickListener(new OnClickListener() {
           public void onClick(View v) {
       
          NotificationManager mgr =  (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
          mgr.cancel(ID);
         
              
        }        
       });
      
   
}
      
      
       private void notifyMe(){
       

        final NotificationManager mgr =  (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
       
        Notification note = new Notification(R.drawable.icon, "알림메시지!", System.currentTimeMillis());
       
     

       
        Intent intent = new Intent(dungTime.this, end.class);
        PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
       
        note.setLatestEventInfo(this, "배변시간체크", "기저귀 확인하세요", pi);
       
        note.number++;
        mgr.notify(ID, note);
       }
       
             
}
       
       
     
라디오 버튼에서 시간을 저장하고, 그 시간 후에 알림이 발생하게 하려고
그런데 이걸 반복되게 하려면 어떻게 해야 하나요?
즉, 라디오버튼에서 15초를 선택후 버튼을 누르면 15초마다 알림이 들어오는거죠..
AlarmManager 쓰는 것 외에는 방법이 없는지 궁금합니다.. 사실 알람매니저는 잘 몰라서요..-_-;;
어떤식으로 구현하면 되는지 작은 힌트라도 주셨으면 합니다..ㅜ.ㅜ