Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>AND YOU are able to use this other ans also...</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, 0); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 01); cal.set(Calendar.SECOND, 0); setAlarm(cal); cal.set(Calendar.HOUR_OF_DAY, 12); cal.set(Calendar.MINUTE, 30); setAlarm(cal); //etc } public void setAlarm(Calendar cal) { try { Intent intent = new Intent(Alarm.this, Alarm1.class); PendingIntent sender = PendingIntent.getBroadcast(this, 1234567, intent, 0); PendingIntent sende2 = PendingIntent.getBroadcast(this, 123123, intent, 0); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender); // to be alerted 30 seconds from now am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sende2); // to be alerted 15 seconds from now /* To show how alarms are cancelled we will create a new Intent and a new PendingIntent with the * same requestCode as the PendingIntent alarm we want to cancel. In this case, it is 1234567. * Note: The intent and PendingIntent have to be the same as the ones used to create the alarms. */ Intent intent1 = new Intent(Alarm.this, Alarm1.class); PendingIntent sender1 = PendingIntent.getBroadcast(this, 1234567, intent1, 0); AlarmManager am1 = (AlarmManager) getSystemService(ALARM_SERVICE); am1.cancel(sender1); } catch (Exception e) { Log.e(TAG, "ERROR IN CODE:"+e.toString()); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload