I can not load web pages using webview,Nothing is displayed,
this url "http://dev.51yunche.com:7000/WeChat/Service%20introduce.html",
this is my webview
webView = (WebView) findViewById(R.id.drive_web);
webView.setWebViewClient(new WebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setDomStorageEnabled(true);//DOM Storage
webView.loadUrl("http://dev.51yunche.com:7000/WeChat/Service%20introduce.html");
this xml:
<WebView
android:id="#+id/drive_web"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
The console does not have any prompts or error messages。I'd like to hear some input from more experienced WebView users (and developers?).
Thank you in advance!
This is not webview Issue.In web browser also that url display Nothing.check that Backend or design code of your html file.
You have a space encoded character %20 in your URL...
use a valid url like:
webView.loadUrl("http://dev.51yunche.com:7000/WeChat/Serviceintroduce.html");
Alternatively you can also try URLEncoder.encode(YOUR_URL); function to encode the Url
Your link itself doesn't display anything in web browser. If you still have any doubt, just simply create a normal html page by yourself and run it from your local system and check it out.
Related
i need to know how to load Survey Form dynamically from my web url and show it in android.
For that you have to use WebView.
in your OnCreate() method use following code
WebView browser = (WebView) findViewById(R.id.webview);
browser.loadUrl("http://www.tutorialspoint.com");
Tutorial for implementing the complete solution : Open URL in WebView.
I ahve a webview in my layout screen. I need to display a PDF file in that webview from my assets folder. I tried below code. While running app displays zoom in and out controls with a blank page(our PDF file is kind of large.is it due to that?).
webView = (WebView) findViewById(R.id.webView1);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.JELLY_BEAN) //required for running javascript on android 4.1 or later
{
settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
}
settings.setBuiltInZoomControls(true);
webView.setWebChromeClient(new WebChromeClient());
webView.loadUrl("file:///android_asset/test.pdf");
I dont want to use external apps to read my PDF. is it possible?then how?
You can use pdf.js from Mozilla to display a PDF in a webview inside an Android application.
Here is the solution...
https://stackoverflow.com/a/21383356/2260073
This question is answered already . For the details refer the following links.
How to read pdf in my android application?.
One more is
stackoverflow.com/questions/10299839/how-to-read-pdf-in-my-android-application/10352422#10352422
After searching a lot about this i came up with my own kind of solution
I used this website to convert my PDF to DOCX and then DOCX to HTML using online converters and then used the following code to load the HTML in my Webview.
String htmlString = "<p>YOUR HTML CODE</p>";
webView.loadData(htmlString, "text/html", "UTF-8");
Hope this helps!
In my application on click of a button i am trying to launch the following url using a web view :
https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore
My code is as below:
WebView webView=new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
webView.loadUrl("https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore");
When the web view appears it first displays the following:
And immediately displays the following:
I do not get to see the maps. Am i missing on something in my code. Can someone kindly help me with this please. Thanks in advance.
I had the same issue in using Google Maps URL into a ColorBox popup.
I found out that you can add &output=embed at the end of the URL to make it show in an iframe.
Maybe this solution will help you too.
So try:
webView.loadUrl("https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore&output=embed");
i found that WebView does not support javascript by default, and this will lead google map jump to a URL that contains a params "nojs",
so, just add this line for your webview, problem gone.
webview.getSettings().setJavaScriptEnabled(true);
In my app,I have link http://mymobilece.com/api/api_getexammaterials.php?id=28,
I want to view in webview ,I try with google document viewer its work fine But i need it without google document viewer,How to show it??
you can use the js for google Doc viever
myScript="<html><iframe src='http://docs.google.com/gview?
url='http://mymobilece.com/api/api_getexammaterials.php?
id=28'&embedded='true' style='width:600px; height:500px;'
frameborder='0'></iframe></html>"
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadData(myscript,"text/html", "UTF-8");
you can use myscript as string variable and use this javascript code(please make sure to remove double quite if above code) and load in webview
You can change the url - width- height variables according to your scripting.
Docs.google.com has a document parser , which basically parses MS-Office files , thats why you can view it on google docs. without that you will have to write document parser. Which will parse files and fetch the contents to display on view. In Short it will be not a good idea to do that. :)
i tried to load the url ww.youtube.com on my app in a webview. but it cant be load completely. it loads just like below image. in the browser it loads comfortably. why? Any Idea?
image http://www.freeimagehosting.net/uploads/d7356dd8e1.png
the simple answer is to call the youtube app thats loaded on every phone with your webview. check out the code on http://fluxkore.com/index.php/android-apps/ to call the youtube app.....
Enable JavaScript! =)
myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("http://www.youtube.com");
It might be a problem with WebViews - WebViews aren't fully fledged browsers, and have limited functionality. For example, the reference page specifically says that WebViews don't handle JavaScripts. If JavaScripts, Flash or something like that is required to properly load YouTube, then that could be why the WebView doesn't handle it properly.