title: android: Alarmmannager force stop the application
body: <p>I'm using alarmmanager class to schedule notification for the user to lunch every day in a certain time but when th time comes it force stop the application
  this is the setAlarm() method that i call onCreate of the main activity</p>
  
  <pre><code>    public void setAlarm() {
      // TODO Auto-generated method stub
      AlarmManager alarmMgr;
      PendingIntent alarmIntent;
  
      alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
      Intent intent = new Intent(this, AlarmReceiver.class);
      alarmIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
  
      // Set the alarm to start at approximately 8:00 p.m.
      Calendar calendar = Calendar.getInstance();
      calendar.setTimeInMillis(System.currentTimeMillis());
      calendar.set(Calendar.HOUR_OF_DAY, 10);
      calendar.set(Calendar.MINUTE, 17);
      // With setInexactRepeating(), you have to use one of the AlarmManager
      // interval
      // constants--in this case, AlarmManager.INTERVAL_DAY.
      alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY,
              alarmIntent);
  }
  </code></pre>
  
  <p>and that's the the BroadcastReceiver Class</p>
  
  <pre><code>public class AlarmReceiver extends BroadcastReceiver {
  
  @Override
  public void onReceive(Context context, Intent arg1) {
      creatNotification(context, "Times Up", "5 Seconds Passed", "Alert");
  }
  
  private void creatNotification(Context context, String MSG, String MSgText, String MSGAlert) {
      PendingIntent NotifIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
      NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context);
      notifBuilder.setContentTitle("title").setContentText("Content")
              .setTicker("Ticker").setSmallIcon(R.drawable.ic_launcher);
      notifBuilder.setContentIntent(NotifIntent);
      notifBuilder.setDefaults(NotificationCompat.DEFAULT_SOUND);
      notifBuilder.setAutoCancel(true);
      NotificationManager notificationManager = (NotificationManager) context
              .getSystemService(Context.NOTIFICATION_SERVICE);
      notificationManager.notify(1, notifBuilder.build());
  }
  </code></pre>
  
  <p>any Ideas ??</p>