I am trying to print webview html in android api 19. PrintDocumentAdapter is added in api level 19 according to doc
https://developer.android.com/reference/android/print/PrintDocumentAdapter.html
and
https://developer.android.com/reference/android/print/PrintDocumentAdapter.LayoutResultCallback.html
But i am getting 2 error
Error:(38, 64) error: LayoutResultCallback() is not public in LayoutResultCallback; cannot be accessed from outside package
and
Error:(42, 101) error: WriteResultCallback() is not public in WriteResultCallback; cannot be accessed from outside package
my code is
public void print(final PrintDocumentAdapter printAdapter, final File path, final String fileName) {
printAdapter.onLayout(null, printAttributes, null, new PrintDocumentAdapter.LayoutResultCallback() {
@Override
public void onLayoutFinished(PrintDocumentInfo info, boolean changed) {
printAdapter.onWrite(null, getOutputFile(path, fileName), new CancellationSignal(), new PrintDocumentAdapter.WriteResultCallback()
{
@Override
public void onWriteFinished(PageRange[] pages) {
super.onWriteFinished(pages);
openHome();
}
}
);
}
}, null);
}
Please need help as soon as.
Create a package inside your src folder with the name: android.print. Then create a file there with your "print" method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With