PrintJobInfo

public final class PrintJobInfo
extends Object implements Parcelable

java.lang.Object
   ↳ android.print.PrintJobInfo


This class represents the description of a print job. The print job state includes properties such as its id, print attributes used for generating the content, and so on. Note that the print jobs state may change over time and this class represents a snapshot of this state.

Summary

Nested classes

class PrintJobInfo.Builder

Builder for creating a PrintJobInfo

Constants

int STATE_BLOCKED

Print job state: The print job is blocked.

int STATE_CANCELED

Print job state: The print job is canceled.

int STATE_COMPLETED

Print job state: The print job is successfully printed.

int STATE_CREATED

Print job state: The print job is being created but not yet ready to be printed.

int STATE_FAILED

Print job state: The print job was printing but printing failed.

int STATE_QUEUED

Print job state: The print jobs is created, it is ready to be printed and should be processed.

int STATE_STARTED

Print job state: The print job is being printed.

Inherited constants

Fields

public static final Creator<PrintJobInfo> CREATOR

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

int getAdvancedIntOption(String key)

Gets the value of an advanced (printer specific) print option.

String getAdvancedStringOption(String key)

Gets the value of an advanced (printer specific) print option.

PrintAttributes getAttributes()

Gets the print job attributes.

int getCopies()

Gets the number of copies.

long getCreationTime()

Gets the wall time in millisecond when this print job was created.

PrintJobId getId()

Gets the unique print job id.

String getLabel()

Gets the human readable job label.

PageRange[] getPages()

Gets the included pages.

PrinterId getPrinterId()

Gets the unique target printer id.

int getState()

Gets the current job state.

boolean hasAdvancedOption(String key)

Gets whether this job has a given advanced (printer specific) print option.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel parcel, int flags)

Flatten this object in to a Parcel.

Inherited methods

Constants

STATE_BLOCKED

added in API level 19
public static final int STATE_BLOCKED

Print job state: The print job is blocked.

Next valid states: STATE_FAILED, STATE_CANCELED, STATE_STARTED

Constant Value: 4 (0x00000004)

STATE_CANCELED

added in API level 19
public static final int STATE_CANCELED

Print job state: The print job is canceled. This is a terminal state.

Next valid states: None

Constant Value: 7 (0x00000007)

STATE_COMPLETED

added in API level 19
public static final int STATE_COMPLETED

Print job state: The print job is successfully printed. This is a terminal state.

Next valid states: None

Constant Value: 5 (0x00000005)

STATE_CREATED

added in API level 19
public static final int STATE_CREATED

Print job state: The print job is being created but not yet ready to be printed.

Next valid states: STATE_QUEUED

Constant Value: 1 (0x00000001)

STATE_FAILED

added in API level 19
public static final int STATE_FAILED

Print job state: The print job was printing but printing failed.

Next valid states: STATE_CANCELED, STATE_STARTED

Constant Value: 6 (0x00000006)

STATE_QUEUED

added in API level 19
public static final int STATE_QUEUED

Print job state: The print jobs is created, it is ready to be printed and should be processed.

Next valid states: STATE_STARTED, STATE_FAILED, STATE_CANCELED

Constant Value: 2 (0x00000002)

STATE_STARTED

added in API level 19
public static final int STATE_STARTED

Print job state: The print job is being printed.

Next valid states: STATE_COMPLETED, STATE_FAILED, STATE_CANCELED, STATE_BLOCKED

Constant Value: 3 (0x00000003)

Fields

CREATOR

added in API level 19
public static final Creator<PrintJobInfo> CREATOR

Public methods

describeContents

added in API level 19
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

getAdvancedIntOption

added in API level 26
public int getAdvancedIntOption (String key)

Gets the value of an advanced (printer specific) print option.

Parameters
key String: The option key.

Returns
int The option value.

getAdvancedStringOption

added in API level 26
public String getAdvancedStringOption (String key)

Gets the value of an advanced (printer specific) print option.

Parameters
key String: The option key.

Returns
String The option value.

getAttributes

added in API level 19
public PrintAttributes getAttributes ()

Gets the print job attributes.

Returns
PrintAttributes The attributes.

This value will never be null.

getCopies

added in API level 19
public int getCopies ()

Gets the number of copies.

Returns
int The number of copies or zero if not set.

getCreationTime

added in API level 19
public long getCreationTime ()

Gets the wall time in millisecond when this print job was created.

Returns
long The creation time in milliseconds.

getId

added in API level 19
public PrintJobId getId ()

Gets the unique print job id.

Returns
PrintJobId The id.

This value may be null.

getLabel

added in API level 19
public String getLabel ()

Gets the human readable job label.

Returns
String The label.

This value will never be null.

getPages

added in API level 19
public PageRange[] getPages ()

Gets the included pages.

Returns
PageRange[] The included pages or null if not set.

getPrinterId

added in API level 19
public PrinterId getPrinterId ()

Gets the unique target printer id.

Returns
PrinterId The target printer id.

This value may be null.

getState

added in API level 19
public int getState ()

Gets the current job state.

Returns
int The job state.

Value is STATE_CREATED, STATE_QUEUED, STATE_STARTED, STATE_BLOCKED, STATE_COMPLETED, STATE_FAILED or STATE_CANCELED.

hasAdvancedOption

added in API level 26
public boolean hasAdvancedOption (String key)

Gets whether this job has a given advanced (printer specific) print option.

Parameters
key String: The option key.

Returns
boolean Whether the option is present.

toString

added in API level 19
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())
 

Returns
String a string representation of the object.

writeToParcel

added in API level 19
public void writeToParcel (Parcel parcel, 
                int flags)

Flatten this object in to a Parcel.

Parameters
parcel Parcel: The Parcel in which the object should be written.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.