See Also: PrintDocumentAdapter Members
Base class that provides the content of a document to be printed.
The PrintDocumentAdapter.OnStart callback is always the first call you will receive and is useful for doing one time setup or resource allocation before printing. You will not receive a subsequent call here.
The PrintDocumentAdapter.OnLayout(PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes) callback requires that you layout the content based on the current Android.Print.PrintAttributes. The execution of this method is not considered completed until you invoke one of the methods on the passed in callback instance. Hence, you will not receive a subsequent call to any other method of this class until the execution of this method is complete by invoking one of the callback methods.
The PrintDocumentAdapter.OnWrite(PageRange[], Android.OS.ParcelFileDescriptor, Android.OS.ParcelFileDescriptor, Android.OS.ParcelFileDescriptor) requires that you render and write the content of some pages to the provided destination. The execution of this method is not considered complete until you invoke one of the methods on the passed in callback instance. Hence, you will not receive a subsequent call to any other method of this class until the execution of this method is complete by invoking one of the callback methods. You will never receive a sequence of one or more calls to this method without a previous call to PrintDocumentAdapter.OnLayout(PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes).
The PrintDocumentAdapter.OnFinish callback is always the last call you will receive and is useful for doing one time cleanup or resource deallocation after printing. You will not receive a subsequent call here.
The APIs defined in this class are designed to enable doing part or all of the work on an arbitrary thread. For example, if the printed content does not depend on the UI state, i.e. on what is shown on the screen, then you can offload the entire work on a dedicated thread, thus making your application interactive while the print work is being performed. Note that while your activity is covered by the system print UI and a user cannot interact with it, doing the printing work on the main application thread may affect the performance of your other application components as they are also executed on that thread.
You can also do work on different threads, for example if you print UI content, you can handle PrintDocumentAdapter.OnStart and PrintDocumentAdapter.OnLayout(PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes) on the UI thread (assuming onStart initializes resources needed for layout). This will ensure that the UI does not change while you are laying out the printed content. Then you can handle PrintDocumentAdapter.OnWrite(PageRange[], Android.OS.ParcelFileDescriptor, Android.OS.ParcelFileDescriptor, Android.OS.ParcelFileDescriptor) and PrintDocumentAdapter.OnFinish on another thread. This will ensure that the main thread is busy for a minimal amount of time. Also this assumes that you will generate the printed content in PrintDocumentAdapter.OnLayout(PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes, Android.Print.PrintAttributes) which is not mandatory. If you use multiple threads, you are responsible for proper synchronization.