title: Android app which reminds user in every morning
body: <p>I'm trying to do App which remind user everymorning with push notification. </p>
  
  <p>I have been using AlarmManager, BroadcastReceiver and IntentService.</p>
  
  <p>In code below, I test my AlarmManager with 60 seconds interval. </p>
  
  <p><strong>Problem</strong>: 
  Everything works fine until I shut down my app, alarms not firing anymore.</p>
  
  <p>Any ideas where to go next?</p>
  
  <p>Manifest: </p>
  
  <pre><code>&lt;service
      android:name=".IntentMentor"
      android:exported="false" &gt;
  &lt;/service&gt;
  
  &lt;receiver android:name=".AlertReceiver"
      android:process=":remote"&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>MainActivity: </p>
  
  <pre><code>Intent intent = new Intent(getApplicationContext(), AlertReceiver.class);
  
  final PendingIntent pIntent = PendingIntent.getBroadcast(this, 0,
      intent, PendingIntent.FLAG_UPDATE_CURRENT);
  
  long firstMillis = System.currentTimeMillis();
  AlarmManager alarm = (AlarmManager)this.getSystemService(Context.ALARM_SERVICE);
  // 1s is only for testing
  alarm.setInexactRepeating(AlarmManager.RTC_WAKEUP, firstMillis, 1000*60, pIntent);
  </code></pre>
  
  <p>Receiver:</p>
  
  <pre><code>public class AlertReceiver extends BroadcastReceiver {
  
      private static final String TAG = "MyReceiver";
  
      @Override
      public void onReceive(Context context, Intent intent) {
          Log.d(TAG, "MyReceiver on receive");
          Intent i = new Intent(context, IntentMentor.class);
          context.startService(i);
      }
  }
  </code></pre>
  
  <p>IntentService:</p>
  
  <pre><code>public class IntentMentor extends IntentService {
  
      NotificationManager notificationManager;
      int notifID = 33;
  
      private static final String TAG = "MonitorService";
  
      public IntentMentor() {
          super(TAG);
      }
  
      @Override
      protected void onHandleIntent(Intent intent) {
          Log.d("TAG", "Service method was fired.");
          pushNotification();
      }
  
      public void pushNotification(){
          NotificationCompat.Builder notificBuilder = new NotificationCompat.Builder(this);
          notificBuilder.setContentTitle("test");
          notificBuilder.setContentText("this is text");
          notificBuilder.setTicker("this is Ticker?");
          notificBuilder.setSmallIcon(R.drawable.ic_info_black_24dp);
          notificBuilder.setDefaults(NotificationCompat.DEFAULT_SOUND);
  
          Intent intent = new Intent(this, Card.class);
  
          TaskStackBuilder tStackBuilder = TaskStackBuilder.create(this);
          tStackBuilder.addParentStack(Card.class);
          tStackBuilder.addNextIntent(intent);
  
          PendingIntent pendingIntent = tStackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
  
          notificBuilder.setContentIntent(pendingIntent);
  
          notificationManager = (NotificationManager) getSystemService((Context.NOTIFICATION_SERVICE));
          notificationManager.notify(notifID, notificBuilder.build() );
      }
  }
  </code></pre>