Skip to content

Most visited

Recently visited

navigation

PrinterCapabilitiesInfo.Builder

public static final class PrinterCapabilitiesInfo.Builder
extends Object

java.lang.Object
   ↳ android.print.PrinterCapabilitiesInfo.Builder


Builder for creating of a PrinterCapabilitiesInfo. This class is responsible to enforce that all required attributes have at least one default value. In other words, this class creates only well-formed PrinterCapabilitiesInfos.

Look at the individual methods for a reference whether a property is required or if it is optional.

Summary

Public constructors

PrinterCapabilitiesInfo.Builder(PrinterId printerId)

Creates a new instance.

Public methods

PrinterCapabilitiesInfo.Builder addMediaSize(PrintAttributes.MediaSize mediaSize, boolean isDefault)

Adds a supported media size.

PrinterCapabilitiesInfo.Builder addResolution(PrintAttributes.Resolution resolution, boolean isDefault)

Adds a supported resolution.

PrinterCapabilitiesInfo build()

Crates a new PrinterCapabilitiesInfo enforcing that all required properties have been specified.

PrinterCapabilitiesInfo.Builder setColorModes(int colorModes, int defaultColorMode)

Sets the color modes.

PrinterCapabilitiesInfo.Builder setDuplexModes(int duplexModes, int defaultDuplexMode)

Sets the duplex modes.

PrinterCapabilitiesInfo.Builder setMinMargins(PrintAttributes.Margins margins)

Sets the minimal margins.

Inherited methods

From class java.lang.Object

Public constructors

PrinterCapabilitiesInfo.Builder

added in API level 19
PrinterCapabilitiesInfo.Builder (PrinterId printerId)

Creates a new instance.

Parameters
printerId PrinterId: The printer id. Cannot be null.

Throws
IllegalArgumentException If the printer id is null.

Public methods

addMediaSize

added in API level 19
PrinterCapabilitiesInfo.Builder addMediaSize (PrintAttributes.MediaSize mediaSize, 
                boolean isDefault)

Adds a supported media size.

Required: Yes

Parameters
mediaSize PrintAttributes.MediaSize: A media size.

This value must never be null.

isDefault boolean: Whether this is the default.

Returns
PrinterCapabilitiesInfo.Builder This builder.

This value will never be null.

Throws
IllegalArgumentException If set as default and there is already a default.

addResolution

added in API level 19
PrinterCapabilitiesInfo.Builder addResolution (PrintAttributes.Resolution resolution, 
                boolean isDefault)

Adds a supported resolution.

Required: Yes

Parameters
resolution PrintAttributes.Resolution: A resolution.

This value must never be null.

isDefault boolean: Whether this is the default.

Returns
PrinterCapabilitiesInfo.Builder This builder.

This value will never be null.

Throws
IllegalArgumentException If set as default and there is already a default.

build

added in API level 19
PrinterCapabilitiesInfo build ()

Crates a new PrinterCapabilitiesInfo enforcing that all required properties have been specified. See individual methods in this class for reference about required attributes.

Note: If you do not add supported duplex modes, DUPLEX_MODE_NONE will set as the only supported mode and also as the default duplex mode.

Returns
PrinterCapabilitiesInfo A new PrinterCapabilitiesInfo.

This value will never be null.

Throws
IllegalStateException If a required attribute was not specified.

setColorModes

added in API level 19
PrinterCapabilitiesInfo.Builder setColorModes (int colorModes, 
                int defaultColorMode)

Sets the color modes.

Required: Yes

Parameters
colorModes int: The color mode bit mask.

defaultColorMode int: The default color mode.

Returns
PrinterCapabilitiesInfo.Builder This builder.

Note: On platform version 19 (Kitkat) specifying only PrintAttributes#COLOR_MODE_MONOCHROME leads to a print spooler crash. Hence, you should declare either both color modes or PrintAttributes#COLOR_MODE_COLOR.

This value will never be null.

Throws
IllegalArgumentException If color modes contains an invalid mode bit or if the default color mode is invalid.

setDuplexModes

added in API level 23
PrinterCapabilitiesInfo.Builder setDuplexModes (int duplexModes, 
                int defaultDuplexMode)

Sets the duplex modes.

Required: No

Parameters
duplexModes int: The duplex mode bit mask.

defaultDuplexMode int: The default duplex mode.

Returns
PrinterCapabilitiesInfo.Builder This builder.

This value will never be null.

Throws
IllegalArgumentException If duplex modes contains an invalid mode bit or if the default duplex mode is invalid.

setMinMargins

added in API level 19
PrinterCapabilitiesInfo.Builder setMinMargins (PrintAttributes.Margins margins)

Sets the minimal margins. These are the minimal margins the printer physically supports.

Required: Yes

Parameters
margins PrintAttributes.Margins: The margins.

This value must never be null.

Returns
PrinterCapabilitiesInfo.Builder This builder.

This value will never be null.

Throws
IllegalArgumentException If margins are null.
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)