我正在使用mupdf库在我的android应用程序中呈现pdf文件。 当我为pdf指定本地路径时,它在我的应用程序中成功打开,当我编写以下代码来呈现服务器端pdf文件时,它在对话框中显示错误消息,因为无法打开pdf文件
Uri uri = Uri.parse("http://kmmc.in/wp-content/uploads/2014/01/lesson2.pdf");
Intent intent = new Intent(context, MuPDFActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
context.startActivity(intent);
我是Android应用程序开发的新手。
这是我的LogCat:
06-03 10:57:53.517 1645-1645/com.tekinarslan.sample I/art﹕ Not late-enabling -Xcheck:jni (already on)
06-03 10:57:56.676 1645-1665/com.tekinarslan.sample D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-03 10:57:56.717 1645-1645/com.tekinarslan.sample D/﹕ HostConnection::get() New Host Connection established 0xb4a93ec0, tid 1645
06-03 10:57:56.873 1645-1645/com.tekinarslan.sample D/Atlas﹕ Validating map...
06-03 10:57:57.380 1645-1645/com.tekinarslan.sample I/System.out﹕ Trying to open /wp-content/uploads/2014/01/lesson2.pdf
06-03 10:57:57.419 1645-1645/com.tekinarslan.sample W/linker﹕ libmupdf.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
06-03 10:57:57.503 1645-1645/com.tekinarslan.sample E/libmupdf﹕ Opening document...
06-03 10:57:57.504 1645-1645/com.tekinarslan.sample E/libmupdf﹕ error: cannot open /wp-content/uploads/2014/01/lesson2.pdf
06-03 10:57:57.504 1645-1645/com.tekinarslan.sample E/libmupdf﹕ error: cannot load document '/wp-content/uploads/2014/01/lesson2.pdf'
06-03 10:57:57.505 1645-1645/com.tekinarslan.sample E/libmupdf﹕ error: Cannot open document: '/wp-content/uploads/2014/01/lesson2.pdf'
06-03 10:57:57.505 1645-1645/com.tekinarslan.sample E/libmupdf﹕ Failed: Cannot open document: '/wp-content/uploads/2014/01/lesson2.pdf'
06-03 10:57:57.508 1645-1645/com.tekinarslan.sample I/System.out﹕ java.lang.Exception: Cannot open file: /wp-content/uploads/2014/01/lesson2.pdf
06-03 10:57:57.853 1645-1657/com.tekinarslan.sample I/art﹕ Background sticky concurrent mark sweep GC freed 2315(157KB) AllocSpace objects, 0(0B) LOS objects, 20% free, 887KB/1117KB, paused 997us total 139.942ms
06-03 10:57:58.297 1645-1657/com.tekinarslan.sample I/art﹕ Background partial concurrent mark sweep GC freed 358(28KB) AllocSpace objects, 1(81KB) LOS objects, 50% free, 985KB/2009KB, paused 14.274ms total 208.324ms
06-03 10:57:58.482 1645-1645/com.tekinarslan.sample I/Choreographer﹕ Skipped 41 frames! The application may be doing too much work on its main thread.
06-03 10:57:58.601 1645-1665/com.tekinarslan.sample D/﹕ HostConnection::get() New Host Connection established 0xb4b36ff0, tid 1665
06-03 10:57:58.613 1645-1665/com.tekinarslan.sample I/OpenGLRenderer﹕ Initialized EGL, version 1.4
06-03 10:57:58.640 1645-1665/com.tekinarslan.sample D/OpenGLRenderer﹕ Enabling debug mode 0
06-03 10:57:58.655 1645-1665/com.tekinarslan.sample W/EGL_emulation﹕ eglSurfaceAttrib not implemented
06-03 10:57:58.655 1645-1665/com.tekinarslan.sample W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb4b5a240, error=EGL_SUCCESS
06-03 10:57:58.795 1645-1665/com.tekinarslan.sample W/EGL_emulation﹕ eglSurfaceAttrib not implemented
06-03 10:57:58.795 1645-1665/com.tekinarslan.sample W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb4b5a260, error=EGL_SUCCESS
06-03 10:57:59.114 1645-1645/com.tekinarslan.sample I/Choreographer﹕ Skipped 37 frames! The application may be doing too much work on its main thread.
答案 0 :(得分:0)
与Windows演示应用程序不同,Android演示应用程序没有内置的HTTP客户端。所以你不能简单地提供一个URL。
如果您想这样做,您必须自己实施HTTP通信。我相信Windows应用程序使用Curl库,我不知道这是否适用于Android。