Notifications in specific time every day android

前端 未结 2 2026
逝去的感伤
逝去的感伤 2020-12-02 19:46

I\'d like to make an app that let the user decide what time everyday wants him to remind something with notification...

I\'d like to know how am i supposed to trigge

2条回答
  •  时光说笑
    2020-12-02 20:20

    Use alarm manager and put your notification in NotifyService class

    Intent myIntent = new Intent(Current.this , NotifyService.class);     
    AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
    pendingIntent = PendingIntent.getService(ThisApp.this, 0, myIntent, 0);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 12);
    calendar.set(Calendar.MINUTE, 00);
    calendar.set(Calendar.SECOND, 00);
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY , pendingIntent);  //set repeating every 24 hours
    

提交回复
热议问题