Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.util.Log; import java.util.Calendar; public class Main { public static final String TAG = "LocalNotifications"; public static PendingIntent scheduleLocalNotification(Context context, int slot, String title, String message, Long alertTime, int repeat) { Log.i(TAG, "Scheduling local notification"); Intent alertIntent = new Intent(getNotificationName(slot)); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, slot, alertIntent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); if (alarmManager != null) { if (repeat == 0) { alarmManager.set(AlarmManager.RTC_WAKEUP, alertTime, pendingIntent); } else { Calendar alarmStartTime = Calendar.getInstance(); alarmStartTime.add(Calendar.MINUTE, 1); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, alertTime, repeat, pendingIntent); } } return pendingIntent; } public static String getNotificationName(int slot) { return getPackageName() + ".Notification" + slot; } public static String getPackageName() { return "::APP_PACKAGE::"; } }