Code is working on Android 5,6 and 8.1. Just not on my Moto G5 Plus (7.0) test device. A bit confused.
public void startEMAAlarm(){
Log.d(TAG, "startEMAAlarm: in start ema alarm");
Calendar cal = Calendar.getInstance();
long when = cal.getTimeInMillis();
cal.setTimeInMillis(System.currentTimeMillis());
cal.set(Calendar.HOUR_OF_DAY, 10);
cal.set(Calendar.MINUTE, 30);
AlarmManager alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(this, EMAAlarmReciever.class);
startEMAIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 1000 * 60 * 5, startEMAIntent);
Log.d(TAG, "startEMAAlarm: alarm should be set");
}
In my Manifest:
<receiver android:name=".EMAAlarmReciever"/>
When I run it, the log message in onReceive in the EMAAlarmReciever, does NOT run! It does on about 7 other phones though, however I only have one 7.0 device to test on.
I guess I must be missing something simple, just not sure what it can be. Any help appreciated. Thanks!
Ok, the phone in question was a Moto G5 Plus, for some unknown reason it just took 24 hours to start working, whilst the other phones started immediately. Chalk one more problem up to random Android fragmentation.