我安裝this庫,從我的應用程序中的URL查看PDF,但是當我點擊該文件以打開它給了我下面的錯誤:Android的PDF查看器,FileNotFoundException異常
我試圖尋找到ContentResolver的,但沒有運氣
這是logcat的:
07-26 15:35:45.638 8725-8725/com.focuson.iapp.firstapp E/PDFView: load pdf error
java.io.FileNotFoundException: No content provider: http://pub.mylaravel.eu/assets/user_files/3/file_no_1.pdf
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1093)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:944)
at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:797)
at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:751)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.getSeekableFileDescriptor(DecodingAsyncTask.java:82)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:61)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:30)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
我活動是:
public class pdfActivity extends AppCompatActivity {
PDFView pdfView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pdf);
pdfView= (PDFView) findViewById(R.id.pdfView);
String url=getIntent().getStringExtra("url");
Log.i("URI-URL",String.valueOf(Uri.parse(url)));
pdfView.fromUri(Uri.parse(url))
.enableSwipe(true)
.enableDoubletap(true)
.swipeVertical(false)
.defaultPage(1)
.showMinimap(false)
.onLoad(new OnLoadCompleteListener() {
@Override
public void loadComplete(int nbPages) {
}
})
.onPageChange(new OnPageChangeListener() {
@Override
public void onPageChanged(int page, int pageCount) {
}
})
.enableAnnotationRendering(false)
.password(null)
.load();}}
我XML是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.focuson.iapp.firstapp.page_types.Login.pdfActivity">
<com.github.barteksc.pdfviewer.PDFView
android:id="@+id/pdfView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
你能訪問手機上的瀏覽器網址? –
是的,它開始下載我的手機上的pdf –
我猜圖書館期望一個ContentProvider的URI,而不是一個網絡地址 –