It is necessary that the notification comes at a specified time (reminder type application), my notification comes immediately, without paying attention to the specified time (10 API).
public class NotificationService extends Service{ NotificationManager nm; Notification notif; @Override public void onCreate() { super.onCreate(); nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); } @Override public int onStartCommand(Intent intent, int flags, int startId) { sendNotif(intent); stopService(intent); return super.onStartCommand(intent, flags, startId); } void sendNotif(Intent mIntent) { AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Intent intent = new Intent(this, MainActivity.class); String movie_title = mIntent.getStringExtra("curmovie"); intent.putExtra(MainActivity.NOTIF_MOVIE, movie_title); PendingIntent pIntent = PendingIntent.getBroadcast(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT); Calendar calendar = Calendar.getInstance(); Calendar cal = Calendar.getInstance(); calendar.set(Calendar.YEAR, cal.get(Calendar.YEAR)); calendar.set(Calendar.MONTH, cal.get(Calendar.MONTH)); calendar.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH)); calendar.set(Calendar.HOUR_OF_DAY, 20); calendar.set(Calendar.MINUTE, 42); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pIntent); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setContentIntent(pIntent) .setSmallIcon(R.drawable.ic_launcher) .setLargeIcon(BitmapFactory.decodeResource(getApplication().getResources(), R.drawable.ic_launcher_large)) .setTicker("Check your movies") .setWhen(calendar.getTimeInMillis()) .setContentTitle("Time for watching!") .setContentText(movie_title) .setAutoCancel(true); notif = builder.build(); notif.sound = Uri.parse("android.resource://com.example.kos.checkmovies/" + R.raw.notif_sound); long[] vibrate = new long[]{1000,200,100,500}; notif.vibrate = vibrate; nm.notify(1,notif); } @Override public IBinder onBind(Intent intent) { return null; } }