Note that there are some explanatory texts on larger screens.

plurals
  1. POOnly Second Alarm is executing why?
    primarykey
    data
    text
    <p>I have two AlarmManager in my activity as follows, </p> <pre><code>public class MainActivity extends Activity { private AlarmManager alarm1,alarm2; private Intent intent1,intent2; private PendingIntent pi1,pi2; private int HOUR=15,MINUTE=46,SECOND=10; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Calendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getDefault()); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, HOUR ); calendar.set(Calendar.MINUTE, MINUTE ); calendar.set(Calendar.SECOND, SECOND ); intent1 = new Intent ( MainActivity.this, BroadCastAlarm.class ); pi1 = PendingIntent.getService( MainActivity.this, 0, intent1, PendingIntent.FLAG_CANCEL_CURRENT ); alarm1 = (AlarmManager) getSystemService( ALARM_SERVICE ); alarm1.set( AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pi1 ); Calendar calendar1 = new GregorianCalendar(); calendar1.setTimeZone(TimeZone.getDefault()); calendar1.setTimeInMillis(System.currentTimeMillis()); calendar1.set(Calendar.HOUR_OF_DAY, HOUR ); calendar1.set(Calendar.MINUTE, MINUTE ); calendar1.set(Calendar.SECOND, SECOND+30 ); intent2 = new Intent ( MainActivity.this, BroadCastAlarm.class ); pi2 = PendingIntent.getService( MainActivity.this, 1, intent2, PendingIntent.FLAG_CANCEL_CURRENT ); alarm2 = (AlarmManager) getSystemService( ALARM_SERVICE ); alarm2.set( AlarmManager.RTC_WAKEUP, calendar1.getTimeInMillis(), pi2 ); } } </code></pre> <p>BroadCastAlarm.java is only a service that display Toast message. Here whenever I am executing above code only second Alarm is getting execute. How come first Alarm is not getting executed ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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