LocalNotificationRequest

constructor(requestId: Int)

Creates a LocalNotificationRequest instance with the specified request ID.

This constructor is typically used to recreate a request object from a previously saved request ID, allowing you to cancel or manage notifications scheduled in previous app sessions. Example:


  // Retrieve saved request ID from storage
  SharedPreferences prefs = context.getSharedPreferences("app_prefs", MODE_PRIVATE);
  int savedRequestId = prefs.getInt("cart_reminder_id", -1);

  if (savedRequestId != -1) {
      // Recreate the request and cancel it
      LocalNotificationRequest request = new LocalNotificationRequest(savedRequestId);
      request.cancel();

      // Remove from storage
      prefs.edit().remove("cart_reminder_id").apply();
  }

Parameters

requestId

the unique request ID of the scheduled notification