Tell me, is it possible to programmatically set an alarm for a certain time? If yes, then skip the link to the example, please, or describe how to implement it.
PS Java implementation
Closed due to the fact that it is necessary to reformulate the question so that it is possible to give an objectively correct answer by the participants of iFr0z , AK ♦ , 0xdb , user192664, Eugene Krivenja 18 Nov '18 at 12:08 .
The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .
|
2 answers
Intent myIntent = new Intent(MainActivity.this, MyAlarmService.class); pendingIntent = PendingIntent.getService(MainActivity.this, 0, myIntent, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 0); alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent); - And actually class MyAlarmService what should contain in itself ?? - Giffy Nov.
- blog.mikesir87.io/2013/04/… - Cypher
|
Found a solution to this issue:
Intent i = new Intent(AlarmClock.ACTION_SET_ALARM); i.putExtra(AlarmClock.EXTRA_MESSAGE, "New Alarm"); i.putExtra(AlarmClock.EXTRA_HOUR, hours); i.putExtra(AlarmClock.EXTRA_MINUTES, mins); startActivity(i); |