There is a class that inherits from Service, this class triggers a notification.
public void sendNotification() { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); //Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.androidauthority.com/")); // Context context = getApplicationContext(); Intent intent = new Intent(this,ActivityFragments.class); intent.putExtra("ExamFragment","ExamFragment"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,0); mBuilder.setContentIntent(pendingIntent); mBuilder.setSmallIcon(R.drawable.icon); mBuilder.setContentTitle("Уведомление"); mBuilder.setContentText("Вам нужно срочно проверить результаты"); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 10); calendar.set(Calendar.MILLISECOND, 0); alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent); mNotificationManager.notify(001, mBuilder.build()); } But the button in the fragment:
saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // NotificationService service = new NotificationService(); getActivity().startService(new Intent(getActivity(),NotificationService.class)); } }); When you click a button, the notification is called immediately, how to make it be called after a certain time?