6

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

jlopez
  • 6,287
  • 2
  • 51
  • 90

1 Answers1

7

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.
}
Community
  • 1
  • 1
Angelo
  • 4,288
  • 2
  • 29
  • 37
  • Thank you! This was an awesome answer! You rock koukio! – gsach Feb 27 '13 at 15:55
  • @GeorgeSachin Glad i was able to help you Sachpatzidi! – Angelo Feb 28 '13 at 13:17
  • @Angelo hey, can we implement action bar with this pdfvieweractivity – Dory Nov 18 '13 at 11:42
  • @nads Since the `PdfViewerActivity` extends `android.app.Activity`, you cannot add action bar functionality without modifying the source code of the `PdfViewerActivity`. – Angelo Nov 18 '13 at 12:12
  • @Angelo thnks for reply. Could you suggest me any other pdf viewer library. – Dory Nov 18 '13 at 12:16
  • @nads If you simply want to view pdf files you can open the pdf file through the official Adove Reader application in the Google Play through `Intents` (http://stackoverflow.com/questions/11398239/open-a-pdf-file-programatically). Unfortunately, i do not know any other pdf viewer libraries you can add to you project. – Angelo Nov 18 '13 at 12:22
  • @Angelo thnks. But what if adobe reader app is not install in any device. Will it view pdf or not.. – Dory Nov 19 '13 at 03:42
  • @nads If the user has not installed in his device the adobe reader app, you can redirect him to the Google Play to download it. See for more information [here](http://stackoverflow.com/a/9480211/1482726). – Angelo Nov 19 '13 at 07:34
  • @Angelo thnks this would be a better option. – Dory Nov 19 '13 at 08:26