Я пытался интегрировать эту PDF Viever, и я получаю это краш сообщение:Android - PDF Int. - Новый экземпляр не удалось - не удалось создать экземпляр
05-31 11:20:48.717: D/ddm-heap(235): Got feature list request
05-31 11:21:16.117: D/dalvikvm(235): newInstance failed: p0 i0 [0 a1
05-31 11:21:16.127: D/AndroidRuntime(235): Shutting down VM
05-31 11:21:16.127: W/dalvikvm(235): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
05-31 11:21:16.127: E/AndroidRuntime(235): Uncaught handler: thread main exiting due to uncaught exception
05-31 11:21:16.137: E/AndroidRuntime(235): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{net.sf.andpdf.pdfviewer/net.sf.andpdf.pdfviewer.PdfViewerActivity}:
java.lang.InstantiationException: net.sf.andpdf.pdfviewer.PdfViewerActivity
05-31 11:21:16.137: E/AndroidRuntime(235): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
Это то, что я пытаюсь реализовать: https://github.com/jblough/Android-Pdf-Viewer-Library
текст справки для интеграции деятельности говорит:
1) Add PdfViewer.jar into your project's build path
2) Copy the following drawable resources from PdfViewer/res/drawable into YourProject/res/drawable
left_arrow.png
right_arrow.png
zoom_in.png
zoom_out.png
3) Copy the following layout resources from PdfViewer/res/layout into YourProject/res/layout
dialog_pagenumber.xml
pdf_file_password.xml
!!THIS IS WHERE THE PROBLEM LIES!! - SE BELOW
4) ***Derive your PDF activity from net.sf.andpdf.pdfviewer.PdfViewerActivity***
5) Using the default drawables and layouts:
public int getPreviousPageImageResource() { return R.drawable.left_arrow; }
public int getNextPageImageResource() { return R.drawable.right_arrow; }
public int getZoomInImageResource() { return R.drawable.zoom_in; }
public int getZoomOutImageResource() { return R.drawable.zoom_out; }
public int getPdfPasswordLayoutResource() { return R.layout.pdf_file_password; }
public int getPdfPageNumberResource() { return R.layout.dialog_pagenumber; }
public int getPdfPasswordEditField() { return R.id.etPassword; }
public int getPdfPasswordOkButton() { return R.id.btOK; }
public int getPdfPasswordExitButton() { return R.id.btExit; }
public int getPdfPageNumberEditField() { return R.id.pagenum_edit; }
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);
Я попытался интегрировать PdfViewer деятельности .jar как Внешний JAR или его реализации в папке активов и загрузки Jar оттуда. Активность PdfViewer находится в папке класса src (sf.net.andpdf .....), которую я также назвал 100%, как код был «создан».
Manifest:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".Niels"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PdfViewerActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.PDFVIEWERACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".PdfViewerActivity" />
</application>
Niels.Java:
public void onClick(View v) {
switch (v.getId()) {
case R.id.button1 :
try{
Intent intent = new Intent(this, PdfViewerActivity.class /*i called this without "Your" as the actual class is named without "Your"*/);
intent.putExtra(net.sf.andpdf.pdfviewer.PdfViewerActivity.EXTRA_PDFFILENAME, "R.drawable.untitled" /*-> untitled.pdf*/);
startActivity(intent); }
catch (Exception e){
e.printStackTrace();
}
Поэтому любые идеи, что я делаю неправильно?
«java.lang.InstantiationException», по-видимому, подразумевает, что они означают ** бизнес ** с маркой №4 «Вывести свою деятельность в формате PDF из net.sf.andpdf.pdfviewer.PdfViewerActivity» - она выбрасывается из-за того, что класс пытался создать ** abstract **. Вы должны сделать подкласс этой «Деятельности» и добавить это вместо своего AndroidManifest.xml. – Jens
Да, у меня было чувство, что я не прочитал эту часть правильно. – Niels
Я сделал обновление, потому что теперь у меня проблема с «невозможностью разрешить суперкласс» – Niels