Code example for AtomicBoolean

Methods: getAndSet

0
			startAlarms(context);
		} 
	} 
 
	private void startAlarms(Context context) {
		boolean started = startedAlarms.getAndSet(true);
		if(!started) {
			 
			AlarmManager mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
			 
			Intent p2 = new Intent(context, CheckEventsReceiver.class);
			PendingIntent pendingIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, p2, PendingIntent.FLAG_UPDATE_CURRENT);
			 
			mAlarmManager.cancel(pendingIntent);
			mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (5 * 1000), 30 * 1000, pendingIntent);
			Log.i("bcr", "Started alarms for events receiver");
		} 
	} 
	 
}