title: My Notification doesn't show after closing the app
body: <p>I have a notification that will show in custom time and date, and everything works fine, but when the app is closed, the notification doesn't show any more. I have used AlarmManager to show notification at specific time.</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>import android.app.AlarmManager;
  import android.app.NotificationManager;
  import android.app.PendingIntent;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.media.RingtoneManager;
  import android.support.v4.app.NotificationCompat;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import java.util.Calendar;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          AlarmManager alarmManager=(AlarmManager)this.getSystemService(Context.ALARM_SERVICE);
          Receiver receiver=new Receiver();
          IntentFilter intentFilter=new IntentFilter("ALARM_ACTION");
          registerReceiver(receiver, intentFilter);
          Intent intent = new Intent("ALARM_ACTION");
          intent.putExtra("param", "My scheduled action");
          PendingIntent operation = PendingIntent.getBroadcast(this, 0, intent, 0);
  
          Calendar calendar=Calendar.getInstance();
          calendar.setTimeInMillis(System.currentTimeMillis());
          calendar.clear();
          calendar.set(Calendar.DATE,26);
          calendar.set(Calendar.MONTH,Calendar.MARCH);
          calendar.set(Calendar.YEAR,2018);
          calendar.set(Calendar.HOUR_OF_DAY, 16);
          calendar.set(Calendar.MINUTE, 52);
          calendar.set(Calendar.SECOND, 0);
  
          alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), operation) ;
      }
  
      private void addNotification() {
          Intent intent = new Intent(this, SecondActivity.class);
          PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  
          NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "ChannelID");
          builder.setSmallIcon(R.drawable.ic_launcher_background);
          builder.setContentTitle("Notifications Example");
          builder.setContentText("This is a test notification");
          builder.setContentIntent(pendingIntent);
          builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
          builder.setAutoCancel(true);
  
          NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
          notificationManager.notify(0, builder.build());
      }
  
      public class Receiver extends BroadcastReceiver{
  
          @Override
          public void onReceive(Context context, Intent intent) {
              addNotification();
          }
      }
  }
  </code></pre>
  
  <p>and <strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.arantik.test"&gt;
  
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;receiver
              android:name=".Receiver"
              android:enabled="true"
              android:exported="true"
              android:label="StartMyServiceAtBootReceiver"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  
          &lt;activity android:name=".SecondActivity"&gt;&lt;/activity&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>