Android webview - loading a html page with .dae model - android

I am trying to load a HTML page which will have an option to choose the .dae file(3d model) using file explorer and it should be loaded in webview. This is working fine in chrome browser but not in webview.
I have enabled the below settings.
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setAllowContentAccess(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDomStorageEnabled(true);
I am able to choose the .dae file and after that nothing happens. Whereas it's loading the 3D model in chrome browser of the device.
Can someone help me on this? Do I need to enable any other settings? Thanks in advance.

Mobile webview is not the Movile browser, they have different render ability.
WebView is render ability cannot match the browser.
To sove this, use XWalkView of crosswalk to replace webview.
How to use crosswalk to render 3D models refer to my answer here.

Related

Opening a tab with a PDF attachment in a Webview

We are trying to allow our users to download / display PDF files in a web application (WebView)
The HTML is a simple
<iframe src="path/to/pdf" />
In a standard android browser everything works - when clicking the link, the browser is allowing either display the PDF, or download... (content-type is application/pdf)
When using the webview we do not get the same results - a blank page is showing, (maybe a new tab is not opening correctly?!)
Note - We cannot use Google Viewer - the PDF is in a user restricted area (a session is required) - and so we cannot provide a public link to the PDF, which is required for google viewer to work.
How can we make the webview work just like the regular browser?
HTML is simple but it contains many css, javascript/jquery code dependencies. Which browser renders accordingly and javascript can run on browsers. As browsers are preconfigured to run javascript and render html css.
Android webview is not preconfigured to run javascript, css. It can render html only. So it looks weird in webview as it renders without css and does not run javascript
How to configure webview to run css and javascript, allow go forward in webview and go backword like browser?
Here are full properties listed. Android developers
Then your webview can let users download the file present there..
WebView mWebView = findViewById(R.id.myWebView);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebChromeClient(new MyWebChromeClient((Activity)mContext));
mWebView.addJavascriptInterface(new testClass(), "jsinterface");
mWebView.loadUrl("UrlToLoad");
You need to append http://docs.google.com/gview?embedded=true&url= to open PDF file in Webview
String docInitialUrl = "http://docs.google.com/gview?embedded=true&url="+docUrl;
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
webView.setInitialScale(100);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(docInitialUrl);

Android HTML WebView

I am creating an application and I am trying to load a HTML page in a web view.
I am using the code
WebView webView = (WebView)findViewById(R.id.webview);
webView.loadUrl("file:///android_asset/index.html");
but continue to receive an error that the web page at file:///android_asset/index.html might be temporarily down or it may have moved permanently to a new web address.
Any help would be great
from assets folder
webview.loadUrl("file:///android_asset/file.html");
from specific folder
webview.loadUrl("file:///data/data/com.example.example/files/file.html");

Whoops! There was a ...previewing this pdf document android

My application has a list of pdf inside listview. The pdf is viewed inside the application using a webview that open a Google Docs sheet. It works fine for the first opened PDF, but
when going back and opening another PDF I got the error "whoops! There was a problem previewing this document". Is there some kind of limitation on opening PDF using google sheet. If so, how can I get full rights to open any PDF I want. can someone help please. Here is my code.
//---you need this to prevent the webview from
// launching another browser when a url
// redirection occurs---
wv.setWebViewClient(new Callback());
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setAllowFileAccess(true);
wv.loadUrl("https://docs.google.com/gview?embedded=true&url=" + SharepreferenceController.getPrefSavePdfInfo());
Try increasing the Version/Compatibility of the PDF. This worked for me.
Edit: I believe it is more of a size issue. When I changed the Version (from Acrobat 9.0 to 10.0) I had also optimized the PDF making it a smaller file. My larger files of the same Version still do not work.
I was having the same issue. What solved it for me was clearing the WebView cache before trying to load another PDF.
WebView webView=(WebView)findViewById(R.id.webView);
webView.clearCache(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://docs.google.com/viewer?url=" + url);

Hosting HTML page locally in Android Device

I am developing an android app. In that I have used webview to open the html page.
But some of the features on my HTML page would work only if I access the page through server.
How can I host the HTML page locally on my Android device?
For better Idea:
Example: On PC, I have hosted the html page locally using Apache Tomcat Server.
So to load this HTML page, I have two options
1. Directly double clicking the HTML and opening in browser.
2. Using URL: http://localhost:8080/MyWebApp
The first option is basic and some of features are not supported.
In second approach, all the features work as expected.
Is there any app/sdk/ open source which I can use to locally host the HTML page?``
try this code
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
//webView.loadUrl("file:///android_asset/folderName/index.html");
webView.loadUrl("http://10.0.2.2:8080/MyWebApp");
Put your file to assets folder and write this
webView.loadUrl("file:///android_asset/help.html");

swf into webview

I want to display swf into a webview. The swf didn't display in the web view. I have this message fail(the browser should render some flash content, not this).
So I try this code. But I am getting ,swf file in encoded form in webview.
What to do to display this swf??
String url ="file:///android_asset/hoge.swf";
WebView wv=(WebView) findViewById(R.id.WebView01);
wv.getSettings().setPluginsEnabled(true);
wv.loadUrl(url);
swf is a flash file.
to be able to display flash file, the device should be supporting flash. recently, there's many android device not support flash. so you must be careful. also check whether the device is already installed flash plugin or not.
Lots of questions have been posted regarding this. Check out this question Load an SWF into a WebView
The author their says that you must enable plugins for thewebview
webview.getSettings().setPluginsEnabled(true);

Categories

Resources