title: Scheduled Notifications Triggers Every Time I Open App
body: <p>I am building an app which triggers a notification at 11:30 IST..I have Tested It Its Working But After 11:30 Whenever i open my app it issues a notification...</p>
  
  <p>i don't know why i think it should be some error in condition in time checking...</p>
  
  <p>i want notification to be triggered on time only once in a day...and then the next day...:) </p>
  
  <p>please resolve this 
  thanks in advance</p>
  
  <pre><code>**MainActivity.java**
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  spinner = (ProgressBar)findViewById(R.id.progressBar);
  spinner.setVisibility(View.GONE);
  Calendar calendar = Calendar.getInstance();
  calendar.set(Calendar.HOUR_OF_DAY, 11);
  calendar.set(Calendar.MINUTE, 30);
  calendar.set(Calendar.SECOND, 00);
  Intent intent1 = new Intent(MainActivity.this, AlarmReciever.class);
  PendingIntent pendingIntent   = PendingIntent.getBroadcast(MainActivity.this,0,intent1, PendingIntent.FLAG_UPDATE_CURRENT);
      AlarmManager am = (AlarmManager) MainActivity.this.getSystemService(MainActivity.this.ALARM_SERVICE);
      am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
  }
  
  
  **AlarmReciever.java**
  
  package com.alivestats.alivestats;
  
  import android.app.NotificationManager;
  import android.app.PendingIntent;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.media.RingtoneManager;
  import android.net.Uri;
  import android.support.v4.app.NotificationCompat;
  public class AlarmReciever extends BroadcastReceiver{
  
  @Override
  public void onReceive(Context context, Intent intent) {
      // TODO Auto-generated method stub
      int MID = 1;
  
      long when = System.currentTimeMillis();
      NotificationManager notificationManager = (NotificationManager) context
              .getSystemService(Context.NOTIFICATION_SERVICE);
  
      Intent notificationIntent = new Intent(context, MainActivity.class);
      notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  
      PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
              notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  
  
      Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
  
      NotificationCompat.Builder mNotifyBuilder = new NotificationCompat.Builder(
              context).setSmallIcon(R.drawable.background)
              .setContentTitle("title")
              .setContentText("description").setSound(alarmSound)
              .setAutoCancel(true).setWhen(when)
              .setContentIntent(pendingIntent)
              .setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
      notificationManager.notify(MID, mNotifyBuilder.build());
      MID++;
  
  }
  
  }
  </code></pre>