Java Code Examples for android.print.PrintJob#isCompleted()
The following examples show how to use
android.print.PrintJob#isCompleted() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProWebView.java From prowebview with Apache License 2.0 | 7 votes |
/** * Print the current web site */ @RequiresApi(19) public void printWebView(@Nullable PrintListener listener) { PrintManager printManager = (PrintManager) getContext().getSystemService(Context.PRINT_SERVICE); PrintDocumentAdapter printAdapter = createPrintDocumentAdapter(); PrintAttributes.Builder builder = new PrintAttributes.Builder(); builder.setMediaSize(PrintAttributes.MediaSize.NA_LETTER); if (printManager != null) { PrintJob printJob = printManager.print(getTitle(), printAdapter, builder.build()); if (listener!=null) { if(printJob.isCompleted()){ listener.onSuccess(); } else { listener.onFailed(); } } } else { if (listener != null) { listener.onFailed(); } } }
Example 2
Source File: MainActivity.java From Android-SmartWebView with MIT License | 5 votes |
private void print_page(WebView view, String print_name, boolean manual) { PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE); PrintDocumentAdapter printAdapter = view.createPrintDocumentAdapter(print_name); PrintAttributes.Builder builder = new PrintAttributes.Builder(); builder.setMediaSize(PrintAttributes.MediaSize.ISO_A5); PrintJob printJob = printManager.print(print_name, printAdapter, builder.build()); if(printJob.isCompleted()){ Toast.makeText(getApplicationContext(), R.string.print_complete, Toast.LENGTH_LONG).show(); } else if(printJob.isFailed()){ Toast.makeText(getApplicationContext(), R.string.print_failed, Toast.LENGTH_LONG).show(); } }