title: Daily local notification by setting time android
body: <p>I am calling TimePickerDialog and based on that user set time, based on the time user will get daily Notification on status bar</p>
  
  <p>I have done by writing below code,</p>
  
  <p>First of all i am calling dialog box by below code </p>
  
  <pre><code>          @Override
  protected Dialog onCreateDialog(int id) {
      switch (id) {
      case TIME_DIALOG_ID:
          // set time picker as current time
          return new TimePickerDialog(this, timePickerListener, hour, minute,
                  true);
  
      }
      return null;
  }
  </code></pre>
  
  <p>Listener method is </p>
  
  <pre><code>     private TimePickerDialog.OnTimeSetListener timePickerListener = new TimePickerDialog.OnTimeSetListener() {
  
      @Override
      public void onTimeSet(TimePicker view, int hourOfDay, int minutes) {
          System.out.println("TimePicker: OnTimeSetLister: hour is "+hourOfDay+": mins"+minutes);
          DailyNotification.registerAlarm(SubscribeMsgTime.this, hourOfDay, minutes);
      }
  
  };
  </code></pre>
  
  <p>i have used BroadCastRecevier in AndroidMenifiast.xml file</p>
  
  <pre><code>        &lt;receiver
          android:name="com.example.easynotification.DailyNotification"
          android:process=":remote" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.example.easynotification.DAILY_NOTIFICATION" /&gt;
              &lt;action android:name="android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE" /&gt;
              &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>And the last DailyNotification (BroadcastReceiver) class is below</p>
  
  <pre><code>public class DailyNotification extends BroadcastReceiver {
  
  
  
  public static void registerAlarm(Context paramContext, int mHour, int mMin) {
      Calendar calendar = Calendar.getInstance();
      if (calendar.get(Calendar.HOUR_OF_DAY) &gt;= mHour) {
          calendar.add(Calendar.DATE, 1);
      }
      calendar.set(Calendar.HOUR_OF_DAY, mHour);
      calendar.set(Calendar.MINUTE, mMin);
      calendar.set(Calendar.SECOND, 00);
  
  
      PendingIntent localPendingIntent = PendingIntent.getBroadcast(
              paramContext, 22341, new Intent(
                      "com.example.easynotification.DAILY_NOTIFICATION"),
              PendingIntent.FLAG_UPDATE_CURRENT);
  
      ((AlarmManager) paramContext.getSystemService("alarm")).setRepeating(1,
              calendar.getTimeInMillis(), 24 * 60 * 60 * 1000,
              localPendingIntent);
      System.out.println("Alarm Registered on Hour :- "+mHour+" : Min "+mMin);
  }
  
  private void showNotification(Context paramContext) {
      try {
          Notification localNotification = new Notification(R.drawable.ic_launcher,
                  paramContext.getString(R.string.app_name),
                  System.currentTimeMillis());
          localNotification.flags = (0x10 | localNotification.flags);
          // PendingIntent that will start the EnterWeightActivity
  
          Intent intent = new Intent(paramContext, MainActivity.class);
          PendingIntent localPendingIntent = PendingIntent.getActivity(
                  paramContext, 0, intent, 0);
  
          localNotification.setLatestEventInfo(paramContext, "hi", "Amit",
                  localPendingIntent);
          // Retrieve a NotificationManager to show the notification
          ((NotificationManager) paramContext
                  .getSystemService("notification")).notify(0,
                  localNotification);
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  @Override
  public void onReceive(Context paramContext, Intent paramIntent) {
      if (paramIntent.getAction().equals(
              "com.example.easynotification.DAILY_NOTIFICATION"))
          showNotification(paramContext);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>but all is working fine dialog box is opening time is registering but notification or onReceive method is not calling please anybody help me </p>