Is it possible to activate an alarm via EditText?

0

I activate my alarm by means of datepicker and timepicker, but I would like to know if it is possible to activate the alarm by means of an editText with mm / dd / yyyy?

My code to activate it by the datepicker and timepicker.

private void setAlarm(Uri passuri){

        Calendar cal = Calendar.getInstance();
        cal.set(datePicker.getYear(),
                datePicker.getMonth(),
                datePicker.getDayOfMonth(),
                timePicker.getCurrentHour(),
                timePicker.getCurrentMinute(),
                00);
        Intent intent = new Intent(getBaseContext(), pruebaintento.dos.notif.AlarmReceiver.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(
                getBaseContext(),
                RQS_1,
                intent,
                PendingIntent.FLAG_CANCEL_CURRENT);

        AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
        alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
    
asked by UserNameYo 08.01.2017 в 19:11
source

1 answer

1

Basically it's the same, just change the way you enter the information to Calendar

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.getDefault());
Calendar cal = Calendar.getInstance();
cal.setTime(sdf.parse(tuEditText.getText().toString()));
    
answered by 10.01.2017 / 16:07
source