I am using mupdf library to render pdf file within my android application. When I am specifying local path for pdf, it open successfully within my app, where as when I write following code to render server side pdf file, it gives error message in dialog box as can not open pdf file
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);
I am new in android application development.
Here is my 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.
The android demo app, unlike thw Windows demo app, has no built-in HTTP client. So you cannot simply provide a URL.
If you want to do this you will have to implement the HTTP communication yourself. I believe that the Windows application uses the Curl library, I have no idea if this is available for Android.