See Also: PrintManager Members
System level service for accessing the printing capabilities of the platform.
java Example
PrintManager printManager = (PrintManager) context.getSystemService(Context.PRINT_SERVICE);
To obtain a handle to the print manager do the following:
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 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.
Print jobs are started by calling the PrintManager.Print(string, Android.Print.PrintDocumentAdapter, Android.Print.PrintDocumentAdapter) 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.
Print jobs can be in PrintJobInfo.StateCreated, PrintJobInfo.StateQueued, PrintJobInfo.StateStarted, PrintJobInfo.StateBlocked, PrintJobInfo.StateCompleted, PrintJobInfo.StateFailed, and PrintJobInfo.StateCanceled 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.
An applications can query the print spooler for current print jobs it created but not print jobs created by other applications.