Example usage for android.print PrintManager getPrintJobs

List of usage examples for android.print PrintManager getPrintJobs

Introduction

In this page you can find the example usage for android.print PrintManager getPrintJobs.

Prototype

public @NonNull List<PrintJob> getPrintJobs() 

Source Link

Document

Gets the print jobs for this application.

Usage

From source file:net.olejon.mdapp.MyTools.java

public void printDocument(WebView webView, String title) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        PrintManager printManager = (PrintManager) mContext.getSystemService(Context.PRINT_SERVICE);

        //noinspection deprecation
        PrintDocumentAdapter printDocumentAdapter = webView.createPrintDocumentAdapter();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
            printDocumentAdapter = webView.createPrintDocumentAdapter(title);

        String documentName = mContext.getString(R.string.project_name) + " - " + title;

        PrintJob printJob = printManager.print(documentName, printDocumentAdapter,
                new PrintAttributes.Builder().build());

        List<PrintJob> printJobs = printManager.getPrintJobs();

        printJobs.add(printJob);//from   www  .j a  v a2  s .c  o m
    } else {
        showToast(mContext.getString(R.string.mytools_printing_not_supported), 1);
    }
}