Multiple broadcasts calling themselves with AlarmManager and BroadcastReceiver
<p>I am building a water-reminder application in Android and I want to remind the user to drink water multiples times during the day without the user having to open the app (so that the intent to the broadcast receiver will be sent). What's the best way to do that? Here's my code:</p>

<p>AlertReceiver.java</p>

<pre><code>import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;

public class AlertReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        createNotification(context, "DRINK", "Time to hydrate", "Alert");
    }

    public void createNotification(Context context, String msg, String msgText, String msgAlert) {

        PendingIntent notificationIntent = PendingIntent.getActivity(context, 0,
                new Intent(context, MainActivity.class), 0);

        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
                .setSmallIcon(R.drawable.ic_announcement)
                .setContentTitle(msg)
                .setContentText(msgText)
                .setTicker(msgAlert);

        notificationBuilder.setContentIntent(notificationIntent);

        notificationBuilder.setDefaults(Notification.DEFAULT_ALL);

        notificationBuilder.setAutoCancel(true);

        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        notificationManager.notify(1, notificationBuilder.build());

    }

}
</code></pre>

<p>Part of MainActivity.java</p>

<pre><code>Long alertTime = nextAlarm.getTimeInMillis();
        Intent alertIntent = new Intent(this, AlertReceiver.class);

        AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);

        alarmManager.set(AlarmManager.RTC_WAKEUP, alertTime,
                PendingIntent.getBroadcast(this, 1, alertIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT));
</code></pre>

<p>Thanks in advance!</p>