78.3 Creating the Custom Print Adapter
Most of the work involved in printing a custom document from within an Android application involves the implementation of the custom print adapter. This example will require a print adapter with the onLayout() and onWrite() callback methods implemented. Within the MainActivity.java file, add the template for this new class so that it reads as follows:
package com.ebookfrenzy.customprint;
.
.
import android.os.CancellationSignal;
import android.os.ParcelFileDescriptor;
import android.print.PageRange;
import android.print.PrintAttributes;
import android.print.PrintDocumentAdapter;
import android.content.Context;
public class MainActivity extends AppCompatActivity {
public static class MyPrintDocumentAdapter extends PrintDocumentAdapter
{
Context context;
&...