android - Can't open a local PDF in webview using file:// -
i need display pdf file located in app dir in webwiev without using google docs.
this code webview:
public void openpdf() { webview webview = new webview(this); setcontentview(webview); webview.getsettings().setjavascriptenabled(true); webview.loadurl("file://mnt/data/data/com.example.android/files/docs/test.pdf");; }
i blank webview instead of below code works
public void openpdf() { webview webview = new webview(this); setcontentview(webview); webview.getsettings().setjavascriptenabled(true); webview.loadurl("file://mnt/data/data/com.example.android/files/docs/test.html"); }
i tested directly in web browser file://mnt/data/data/com.example.android/files/docs/test.pdf
, test.html
, worked both. installed pdf reader.
07-25 17:09:07.967: w/webcore(11347): java.lang.throwable: eventhub.removemessages(int = 107) not supported before webviewcore set up. 07-25 17:09:07.967: w/webcore(11347): @ android.webkit.webviewcore$eventhub.removemessages(webviewcore.java:1683) 07-25 17:09:07.967: w/webcore(11347): @ android.webkit.webviewcore$eventhub.access$7900(webviewcore.java:926) 07-25 17:09:07.967: w/webcore(11347): @ android.webkit.webviewcore.removemessages(webviewcore.java:1795) 07-25 17:09:07.967: w/webcore(11347): @ android.webkit.webview.sendourvisiblerect(webview.java:2917) 07-25 17:09:07.967: w/webcore(11347): @ android.webkit.zoommanager.setzoomscale(zoommanager.java:593) 07-25 17:09:07.967: w/webcore(11347): @ android.webkit.zoommanager.access$1700(zoommanager.java:49) 07-25 17:09:07.967: w/webcore(11347): @ android.webkit.zoommanager$postscale.run(zoommanager.java:984) 07-25 17:09:07.967: w/webcore(11347): @ android.os.handler.handlecallback(handler.java:605) 07-25 17:09:07.967: w/webcore(11347): @ android.os.handler.dispatchmessage(handler.java:92) 07-25 17:09:07.967: w/webcore(11347): @ android.os.looper.loop(looper.java:137) 07-25 17:09:07.967: w/webcore(11347): @ android.app.activitythread.main(activitythread.java:4424) 07-25 17:09:07.967: w/webcore(11347): @ java.lang.reflect.method.invokenative(native method) 07-25 17:09:07.967: w/webcore(11347): @ java.lang.reflect.method.invoke(method.java:511) 07-25 17:09:07.967: w/webcore(11347): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:784) 07-25 17:09:07.967: w/webcore(11347): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:551) 07-25 17:09:07.967: w/webcore(11347): @ dalvik.system.nativestart.main(native method)
any ideas why pdf files won't open ?
their seems answer question in stack overflow @ open local html file in webview - android
to sum : usage of file:/// before actual path should solve problem except .pdf files
webview not support pdf in android :(. need use google doc according different sources.
Comments
Post a Comment