How can I create a reminder using AlarmManager? <p>I tried to make a project that will show <code>Notification</code> on particular time and even the app is not open it will show it. But it is showing message at particular time and also after the given time. Moreover the <code>Notification</code> does not work when the app is closed.</p> <p>How can I stop it permanently after the given time and also run in the background ?</p> <p>code is given below.</p> <pre><code>private PendingIntent pendingIntent; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, Calendar.SEPTEMBER); //calendar.set(Calendar.YEAR, 2016); calendar.set(Calendar.DAY_OF_MONTH, 15); calendar.set(Calendar.HOUR_OF_DAY, 14); calendar.set(Calendar.MINUTE, 24); calendar.set(Calendar.SECOND, 05); //calendar.set(Calendar.AM_PM,Calendar.PM); Intent myIntent = new Intent(MainActivity.this, AlarmReceiver.class); pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0, myIntent,0); AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); alarmManager.set(AlarmManager.RTC, calendar.getTimeInMillis(), pendingIntent); Intent into = new Intent(this, AlarmReceiver.class); PendingIntent ppendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1253, into, 0); AlarmManager alarmManag = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManag.cancel(ppendingIntent); ppendingIntent.(); } @Override public void onReceive(Context context, Intent intent) { Intent service1 = new Intent(context, MyAlarmService.class); context.startService(service1); } </code></pre> <p>Receiver has been added to manifest.</p>