How to set an alarm for a selected date and time?
<p>I have this code from where I can set a time and date from date picker and time picker at once:</p>

<pre><code> private void dialoguetime() {

    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.custom_dialogue);
    dialog.setCancelable(true);
    dialog.setTitle("This is Dialog 1");
    dialog.show();

    TimePicker time_picker = (TimePicker) dialog
            .findViewById(R.id.timePicker1);
    hours = time_picker.getCurrentHour();
    minute = time_picker.getCurrentMinute();
    time_picker.setOnTimeChangedListener(new OnTimeChangedListener() {
        public void onTimeChanged(TimePicker view, int hourOfDay,
                int minutes) {
            // TODO Auto-generated method stub
            // Toast.makeText(CustomDialog.this,
            // "hourOfDay = "+hourOfDay+"minute = "+minute , 1000).show();
            hours = hourOfDay;
            minute = minutes;
        }
    });

    final DatePicker date_picker = (DatePicker) dialog
            .findViewById(R.id.datePicker1);
    Button btn = (Button) dialog.findViewById(R.id.button2);
    btn.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {
            // TODO Auto-generated method stub



            xDate = date_picker.getYear() + "-"+ (date_picker.getMonth() + 1) + "-"+ date_picker.getDayOfMonth() + " " + hours+ ":" + minute + ":00";
            Toast.makeText(
                    getApplicationContext(),
                    xDate, Toast.LENGTH_LONG)
                    .show();
            dialog.cancel();
        }

    }

    );

}
</code></pre>

<p>From this I can get a string as a date format like this <code>yyyy-mm-dd hh:mm:ss</code>, now I want to give an alert (as alarm) to the user of that selected time. I have used alarm manager for this but it didn't allow me to select that date?</p>

<p>How can I do this?</p>
