/**@class android.print.PrintManager @extends java.lang.Object System level service for accessing the printing capabilities of the platform. <h3>Print mechanics</h3> <p> The key idea behind printing on the platform is that the content to be printed should be laid out for the currently selected print options resulting in an optimized output and higher user satisfaction. To achieve this goal the platform declares a contract that the printing application has to follow which is defined by the {@link android.print.PrintDocumentAdapter} class. At a higher level the contract is that when the user selects some options from the print UI that may affect the way content is laid out, for example page size, the application receives a callback allowing it to layout the content to better fit these new constraints. After a layout pass the system may ask the application to render one or more pages one or more times. For example, an application may produce a single column list for smaller page sizes and a multi-column table for larger page sizes. </p> <h3>Print jobs</h3> <p> Print jobs are started by calling the {@link #print(String, PrintDocumentAdapter, android.print.PrintAttributes)} from an activity which results in bringing up the system print UI. Once the print UI is up, when the user changes a selected print option that affects the way content is laid out the system starts to interact with the application following the mechanics described the section above. </p> <p> Print jobs can be in {@link android.print.PrintJobInfo#STATE_CREATED created}, {@link android.print.PrintJobInfo#STATE_QUEUED queued}, {@link android.print.PrintJobInfo#STATE_STARTED started}, {@link android.print.PrintJobInfo#STATE_BLOCKED blocked}, {@link android.print.PrintJobInfo#STATE_COMPLETED completed}, {@link android.print.PrintJobInfo#STATE_FAILED failed}, and {@link android.print.PrintJobInfo#STATE_CANCELED canceled} state. Print jobs are stored in dedicated system spooler until they are handled which is they are cancelled or completed. Active print jobs, ones that are not cancelled or completed, are considered failed if the device reboots as the new boot may be after a very long time. The user may choose to restart such print jobs. Once a print job is queued all relevant content is stored in the system spooler and its lifecycle becomes detached from this of the application that created it. </p> <p> An applications can query the print spooler for current print jobs it created but not print jobs created by other applications. </p> @see PrintJob @see PrintJobInfo */ var PrintManager = { /** Package name of print spooler. @hide */ PRINT_SPOOLER_PACKAGE_NAME : "com.android.printspooler", /** Select enabled services. </p> @see #getPrintServices @hide */ ENABLED_SERVICES : "1", /** Select disabled services. </p> @see #getPrintServices @hide */ DISABLED_SERVICES : "2", /** Select all services. </p> @see #getPrintServices @hide */ ALL_SERVICES : "3", /** The action for launching the print dialog activity. @hide */ ACTION_PRINT_DIALOG : "android.print.PRINT_DIALOG", /** Extra with the intent for starting the print dialog. <p> <strong>Type:</strong> {@link android.content.IntentSender} </p> @hide */ EXTRA_PRINT_DIALOG_INTENT : "android.print.intent.extra.EXTRA_PRINT_DIALOG_INTENT", /** Extra with a print job. <p> <strong>Type:</strong> {@link android.print.PrintJobInfo} </p> @hide */ EXTRA_PRINT_JOB : "android.print.intent.extra.EXTRA_PRINT_JOB", /** Extra with the print document adapter to be printed. <p> <strong>Type:</strong> {@link android.print.IPrintDocumentAdapter} </p> @hide */ EXTRA_PRINT_DOCUMENT_ADAPTER : "android.print.intent.extra.EXTRA_PRINT_DOCUMENT_ADAPTER", /**@hide */ APP_ID_ANY : "-2", /**Creates an instance that can access all print jobs. @param {Number} userId The user id for which to get all print jobs. @return {Object {android.print.PrintManager}} An instance if the caller has the permission to access all print jobs, null otherwise. @hide */ getGlobalPrintManagerForUser : function( ) {}, /**Adds a listener for observing the state of print jobs. @param {Object {PrintManager.PrintJobStateChangeListener}} listener The listener to add. @hide */ addPrintJobStateChangeListener : function( ) {}, /**Removes a listener for observing the state of print jobs. @param {Object {PrintManager.PrintJobStateChangeListener}} listener The listener to remove. @hide */ removePrintJobStateChangeListener : function( ) {}, /**Gets a print job given its id. @param {Object {PrintJobId}} printJobId The id of the print job. @return {Object {android.print.PrintJob}} The print job list. @see PrintJob @hide */ getPrintJob : function( ) {}, /**Get the custom icon for a printer. If the icon is not cached, the icon is requested asynchronously. Once it is available the printer is updated. @param {Object {PrinterId}} printerId the id of the printer the icon should be loaded for @return {Object {android.graphics.drawable.Icon}} the custom icon to be used for the printer or null if the icon is not yet available @see android.print.PrinterInfo.Builder#setHasCustomPrinterIcon(boolean) @hide */ getCustomPrinterIcon : function( ) {}, /**Gets the print jobs for this application. @return {Object {java.util.List}} The print job list. @see PrintJob */ getPrintJobs : function( ) {}, /**Creates a print job for printing a {@link android.print.PrintDocumentAdapter} with default print attributes. <p> Calling this method brings the print UI allowing the user to customize the print job and returns a {@link android.print.PrintJob} object without waiting for the user to customize or confirm the print job. The returned print job instance is in a {@link android.print.PrintJobInfo#STATE_CREATED created} state. <p> This method can be called only from an {@link Activity}. The rationale is that printing from a service will create an inconsistent user experience as the print UI would appear without any context. </p> <p> Also the passed in {@link android.print.PrintDocumentAdapter} will be considered invalid if your activity is finished. The rationale is that once the activity that initiated printing is finished, the provided adapter may be in an inconsistent state as it may depend on the UI presented by the activity. </p> <p> The default print attributes are a hint to the system how the data is to be printed. For example, a photo editor may look at the photo aspect ratio to determine the default orientation and provide a hint whether the printing should be in portrait or landscape. The system will do a best effort to selected the hinted options in the print dialog, given the current printer supports them. </p> <p> <strong>Note:</strong> Calling this method will bring the print dialog and the system will connect to the provided {@link android.print.PrintDocumentAdapter}. If a configuration change occurs that you application does not handle, for example a rotation change, the system will drop the connection to the adapter as the activity has to be recreated and the old adapter may be invalid in this context, hence a new adapter instance is required. As a consequence, if your activity does not handle configuration changes (default behavior), you have to save the state that you were printing and call this method again when your activity is recreated. </p> @param {String} printJobName A name for the new print job which is shown to the user. @param {Object {PrintDocumentAdapter}} documentAdapter An adapter that emits the document to print. @param {Object {PrintAttributes}} attributes The default print job attributes or <code>null</code>. @return {Object {android.print.PrintJob}} The created print job on success or null on failure. @throws IllegalStateException If not called from an {@link Activity}. @throws IllegalArgumentException If the print job name is empty or the document adapter is null. @see PrintJob */ print : function( ) {}, /**Listen for changes to the installed and enabled print services. @param {Object {PrintManager.PrintServicesChangeListener}} listener the listener to add @param {Object {Handler}} handler the handler the listener is called back on @see android.print.PrintManager#getPrintServices @hide */ addPrintServicesChangeListener : function( ) {}, /**Stop listening for changes to the installed and enabled print services. @param {Object {PrintManager.PrintServicesChangeListener}} listener the listener to remove @see android.print.PrintManager#getPrintServices @hide */ removePrintServicesChangeListener : function( ) {}, /**Gets the list of print services, but does not register for updates. The user has to register for updates by itself, or use {@link android.print.PrintServicesLoader}. @param {Number} selectionFlags flags selecting which services to get. Either {@link #ENABLED_SERVICES},{@link #DISABLED_SERVICES}, or both. @return {Object {java.util.List}} The print service list or an empty list. @see #addPrintServicesChangeListener(PrintServicesChangeListener, Handler) @see #removePrintServicesChangeListener(PrintServicesChangeListener) @hide */ getPrintServices : function( ) {}, /**Listen for changes to the print service recommendations. @param {Object {PrintManager.PrintServiceRecommendationsChangeListener}} listener the listener to add @param {Object {Handler}} handler the handler the listener is called back on @see android.print.PrintManager#getPrintServiceRecommendations @hide */ addPrintServiceRecommendationsChangeListener : function( ) {}, /**Stop listening for changes to the print service recommendations. @param {Object {PrintManager.PrintServiceRecommendationsChangeListener}} listener the listener to remove @see android.print.PrintManager#getPrintServiceRecommendations @hide */ removePrintServiceRecommendationsChangeListener : function( ) {}, /**Gets the list of print service recommendations, but does not register for updates. The user has to register for updates by itself, or use {@link android.print.PrintServiceRecommendationsLoader}. @return {Object {java.util.List}} The print service recommendations list or an empty list. @see #addPrintServiceRecommendationsChangeListener @see #removePrintServiceRecommendationsChangeListener @hide */ getPrintServiceRecommendations : function( ) {}, /** @hide */ createPrinterDiscoverySession : function( ) {}, /**Enable or disable a print service. @param {Object {ComponentName}} service The service to enabled or disable @param {Boolean} isEnabled whether the service should be enabled or disabled @hide */ setPrintServiceEnabled : function( ) {}, };