Code example for TimePicker

Methods: getCurrentHourgetCurrentMinutesetEnabled

0
    		} 
            Toast.makeText(this, "Alarm Set For " + Integer.toString(alarmCalendar.get(Calendar.MONTH) + 1) + "/" + Integer.toString(alarmCalendar.get(Calendar.DAY_OF_MONTH)) + "/" + Integer.toString(alarmCalendar.get(Calendar.YEAR)) + " " + CalendarHourStr + ":" + CalendarMinStr + " " + strAmPM, Toast.LENGTH_LONG).show();    	
	 
        } 
        else { 
        	AlarmTimePicker.setEnabled(true);
        	 
        	//Build Intent/Pending Intent for canceling the alarm 
    		Intent AlarmIntent = new Intent(MainActivity.this, AlarmReceiver.class);
        	AlarmManager AlmMgr = (AlarmManager)getSystemService(ALARM_SERVICE);
        	PendingIntent Sender = PendingIntent.getBroadcast(MainActivity.this, 0, AlarmIntent, 0);  
        	AlmMgr.cancel(Sender);
        	 
        	//Display Alarm Disabled Message 
            Toast.makeText(MainActivity.this, "Alarm Disabled", Toast.LENGTH_LONG).show();
        } 
    }  
     
    /** Class for implementing the Enable's Check Box Click Event Listener */ 
    public class AlarmEnableListener implements CheckBox.OnClickListener {
    	public static final String PREFS_NAME = "MyPrefsFile";
    	public static final String ALARM_HOUR = "ALARM_HOUR";
    	public static final String ALARM_MINUTE = "ALARM_MIN";
    	 
    	public void onClick(View v) {
    		//Read State of UI components and call SetAlarm routine 
            AlarmEnabled = EnableCheckBox.isChecked();
            AlarmHour = AlarmTimePicker.getCurrentHour();
            AlarmMin = AlarmTimePicker.getCurrentMinute();
             
            //Call Set Alarm Routine 
            SetAlarm(AlarmEnabled, AlarmHour, AlarmMin);
            Clock.requestFocus();