I am trying to make an alarm application that will take ānā number of times from the user and buzz at those times and stores the difference in the timing so that the next user accesses the application, the stored difference is default. Here is the code of the main activity:
public void startAlert(View view) {
EditText textH = (EditText) findViewById(R.id.hours);
int h = Integer.parseInt(textH.getText().toString());
EditText textM = (EditText) findViewById(R.id.minutes);
int m = Integer.parseInt(textM.getText().toString());
EditText textS = (EditText) findViewById(R.id.seconds);
int s = Integer.parseInt(textS.getText().toString());
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR, h);
cal.set(Calendar.MINUTE, m);
cal.set(Calendar.SECOND, s);
Intent intent = new Intent(this, AlarmService.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
12345, intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
pendingIntent);
Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();
}
I have no idea how to add n number of editTexts
at the runtime? and for the AlarmManager
class...shall i run a loop for creating n number of AlarmManager
objects?