Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement Android Pdf Viewer Library

It seems that it is the only pdf reader for free android that does not depend on MuPDF.

I'm trying to prove it, I have downloaded the project but to run it I get the exception:

01-17 13:45:03.960: E/AndroidRuntime(13631): FATAL EXCEPTION: main
01-17 13:45:03.960: E/AndroidRuntime(13631): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{net.sf.andpdf.pdfviewer/net.sf.andpdf.pdfviewer.PdfViewerActivity}: java.lang.InstantiationException: can't instantiate class net.sf.andpdf.pdfviewer.PdfViewerActivity
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1894)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread.access$600(ActivityThread.java:128)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.os.Looper.loop(Looper.java:137)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread.main(ActivityThread.java:4514)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at java.lang.reflect.Method.invokeNative(Native Method)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at java.lang.reflect.Method.invoke(Method.java:511)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at dalvik.system.NativeStart.main(Native Method)
01-17 13:45:03.960: E/AndroidRuntime(13631): Caused by: java.lang.InstantiationException: can't instantiate class net.sf.andpdf.pdfviewer.PdfViewerActivity
01-17 13:45:03.960: E/AndroidRuntime(13631):    at java.lang.Class.newInstanceImpl(Native Method)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at java.lang.Class.newInstance(Class.java:1319)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.Instrumentation.newActivity(Instrumentation.java:1027)
01-17 13:45:03.960: E/AndroidRuntime(13631):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1885)

In the readme of the project, the last step I can not understand it.

6) Invoke your PdfViewActivity derived with the following code:

 Intent intent = new Intent(this, YourPdfViewerActivity.class);
 intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, "PATH TO PDF GOES HERE");
 startActivity(intent);

Can anyone explain me what this step? Or more important still: someone has been able to use this pdf reader?

Thanks

like image 806
jlopez Avatar asked Jan 17 '13 12:01

jlopez


1 Answers

The problem is that the PdfViewerActivity you are trying to instantiate in your Intent is an abstract class and cannot be instantiated (Link of the class here). You need to create an Activity which extends PdfViewerActivity implementing any abstract method that the class has. Something like this:

public class MyPdfViewerActivity extends PdfViewerActivity {

   //Your implementation code here.
}
like image 81
Angelo Avatar answered Oct 10 '22 06:10

Angelo