Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LayoutResultCallback() is not public in LayoutResultCallback; cannot be accessed from outside package error while generating pdf

Tags:

java

android

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.

like image 784
Mahesh Lad Avatar asked Jun 14 '17 19:06

Mahesh Lad


1 Answers

Create a package inside your src folder with the name: android.print. Then create a file there with your "print" method.

like image 178
Laura Orán Avatar answered Sep 28 '22 06:09

Laura Orán