Note: I tried various solutions that are written about here on StackOverflow (example here). Please do not close this without checking if your solution from what you\'ve fou
I am the author of the open source project you have mentioned in your question (simple alarm clock).
I am surprised that using AlarmManager.setAlarmClock did not work for you, because my app does exactly that. The code is in the file AlarmSetter.kt. Here is a snippet:
val pendingAlarm = Intent(ACTION_FIRED)
.apply {
setClass(mContext, AlarmsReceiver::class.java)
putExtra(EXTRA_ID, id)
putExtra(EXTRA_TYPE, typeName)
}
.let { PendingIntent.getBroadcast(mContext, pendingAlarmRequestCode, it, PendingIntent.FLAG_UPDATE_CURRENT) }
val pendingShowList = PendingIntent.getActivity(
mContext,
100500,
Intent(mContext, AlarmsListActivity::class.java),
PendingIntent.FLAG_UPDATE_CURRENT
)
am.setAlarmClock(AlarmManager.AlarmClockInfo(calendar.timeInMillis, pendingShowList), pendingAlarm)
Basically it is nothing special, just make sure that intent has an action and a target class, which is a broadcast receiver in my case.