setDelay
Sets the delay after which the notification will be displayed.
Important: Delay is specified in seconds, not milliseconds. The notification will be scheduled using Android's android.app.AlarmManager and will be displayed after the specified delay from the moment scheduleLocalNotification is called. Example:
// Schedule notification for 5 minutes from now
LocalNotification fiveMinutes = new LocalNotification.Builder()
.setMessage("5 minute reminder")
.setDelay(300) // 5 minutes = 300 seconds
.build();
// Schedule notification for 1 hour from now
LocalNotification oneHour = new LocalNotification.Builder()
.setMessage("1 hour reminder")
.setDelay(3600) // 1 hour = 3600 seconds
.build();
// Schedule notification for 24 hours from now
LocalNotification oneDay = new LocalNotification.Builder()
.setMessage("Daily reminder")
.setDelay(86400) // 24 hours = 86400 seconds
.build();
// Immediate notification (show in 1 second)
LocalNotification immediate = new LocalNotification.Builder()
.setMessage("Immediate notification")
.setDelay(1) // Minimum practical delay
.build();
Content copied to clipboard
Note: On Android 6.0+ (API 23+), battery optimization may delay exact timing. For time-critical notifications, consider using WorkManager or AlarmManager's exact alarm APIs.
Return
this builder instance for method chaining
Parameters
delay
delay in seconds (must be positive)