alarmmanager every day
<p>I think using a service but an stackoverflow user discourage me because is not the correct way to do. I've the code (below) to execute two notify (notification bar) every day 2 times.</p>

<pre><code>Calendar cal1 = Calendar.getInstance();
        cal1.set(Calendar.HOUR_OF_DAY, 05); midday
        cal1.set(Calendar.MINUTE, 45);
        cal1.set(Calendar.SECOND, 00);

        Calendar cal2 = Calendar.getInstance();
        cal2.set(Calendar.HOUR_OF_DAY, 17);8pm for example
        cal2.set(Calendar.MINUTE, 30);
        cal2.set(Calendar.SECOND, 00);

        AlarmManager am = (AlarmManager)getApplicationContext().getSystemService  (Context.ALARM_SERVICE);
        Intent intent2 = new Intent(getApplicationContext(), AlarmReceiver.class);
        PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(), 0, intent2,      PendingIntent.FLAG_UPDATE_CURRENT);
        am.setRepeating(AlarmManager.RTC_WAKEUP, cal1.getTimeInMillis(),cal2.getTimeInMillis(), pi);
</code></pre>

<p>I've a class AlarmReceiver:</p>

<pre><code>public class AlarmReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {

        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);

        int icon = R.drawable.ic_launcher2;
        CharSequence tickerText = not1[x];
        long when = System.currentTimeMillis();
        Notification notification = new Notification(icon, tickerText, when);
        notification.defaults |= Notification.DEFAULT_SOUND;
        notification.defaults |= Notification.DEFAULT_VIBRATE;
        CharSequence contentTitle = "title";
        CharSequence contentText = "text";
</code></pre>

<p>I don't know how implement the code. Can anyone help me?</p>
