This is the code I have so far
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
setRepeatingAlarm();
public void setRepeatingAlarm() {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.SECOND, 10);
Intent intent = new Intent(this, TimeAlarm.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), (15 * 1000), pendingIntent);
}
}
This is all I am trying to accomplish: The alarm will not turn on until 30 seconds past every minute. Once you clear it, it wont comes back on until 30 seconds past the next minute. So if I open the app, and it is 25 second past the minute, it will activate status bar notification 5 second later. But if it is 40 seconds past, I will have to wait 50 more seconds (into the next minute). I am not sure how to use the Calendar function to attain this?