public final class PrintResult
- Object
- PrintResult
Outcome of a print request initiated through Printer or
Display.print.
Status semantics:
COMPLETED: the print flow finished and the job was handed to the printing system. Platforms generally can’t observe the physical printer, so this means “queued/sent”, not “paper came out”.CANCELLED: the user dismissed the print dialog without printing.FAILED: the job could not be started or the printing system reported an error.getError()may carry a short, platform-supplied description.
Some platforms cannot distinguish cancellation from completion once the
native dialog takes over; those report COMPLETED on a best-effort
basis.
Instances are immutable. Construct through the static factories.
Fields
public static final int STATUS_COMPLETED = 1 | The print job was handed to the platform printing system. |
public static final int STATUS_CANCELLED = 2 | User dismissed/cancelled the print dialog. |
public static final int STATUS_FAILED = 3 | The print job could not be completed. |
Methods
public static PrintResult completed() | Build a COMPLETED result. |
public static PrintResult cancelled() | Build a CANCELLED result. |
public static PrintResult failed(String message) | Build a FAILED result with an optional platform message. |
public int getStatus() | Numeric status: one of STATUS_COMPLETED, STATUS_CANCELLED, STATUS_FAILED. |
public boolean isCompleted() | True iff status == STATUS_COMPLETED. |
public boolean isCancelled() | True iff status == STATUS_CANCELLED. |
public boolean isFailed() | True iff status == STATUS_FAILED. |
public String getError() | Platform-supplied message when isFailed is true, otherwise null. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Field details
STATUS_COMPLETED
public static final int STATUS_COMPLETED = 1The print job was handed to the platform printing system.
STATUS_CANCELLED
public static final int STATUS_CANCELLED = 2User dismissed/cancelled the print dialog.
STATUS_FAILED
public static final int STATUS_FAILED = 3The print job could not be completed.
Method details
completed
public static PrintResult completed()Build a
COMPLETED result.cancelled
public static PrintResult cancelled()Build a
CANCELLED result.failed
public static PrintResult failed(String message)Build a
FAILED result with an optional platform message.getStatus
public int getStatus()isCompleted
public boolean isCompleted()True iff status ==
STATUS_COMPLETED.isCancelled
public boolean isCancelled()True iff status ==
STATUS_CANCELLED.isFailed
public boolean isFailed()True iff status ==
STATUS_FAILED.getError
public String getError()Platform-supplied message when
isFailed is true, otherwise null.toString
public String toString()Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())