We have a webview that we are loading from android_assets. This works fine in 2.1, 2.2, and 2.3. However, when we load it in 3.0, we get a "Webpage not available" message.
This only happens on pages where we are passing parameters to the webview:
WebView webView = (WebView) findViewById(R.id.my_webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(new JavaScriptInterface(this), "androidInterface");
webView.setBackgroundColor(0);
//This works
webView.loadUrl("file:///android_asset/my.html");
//This does not work.
webView.loadUrl("file:///android_asset/my.html" + "?param=value");
Any idea how to get this to work on Honeycomb?
Not answer to the original problem, but a workaround. Since I was already using the JavascriptInterface, I set the value that I wanted to read in Javascript on the JavascriptInterface.
Related
I realized that not working for under android 4.3 versions.
I have an android app which has webview. When i try to load url "http://instagram.com" it's not working It shows blank page but facebook webpage is working.
It's really important for me please help.
WebView view = (WebView) findViewById(R.id.webView1);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl("http://www.instagram.com");
Have you tried using the method:
setDomStorageEnabled();
Sets whether the DOM storage API is enabled. The default value is
false.
for example:
WebView view = (WebView) findViewById(R.id.webView1);
view.getSettings().setJavaScriptEnabled(true);
view.getSettings().setDomStorageEnabled(true);
view.loadUrl("http://www.instagram.com");
I had previously problems loading Facebook and Twitter pages in some devices, solved using setDomStorageEnabled() method.
I have a problem with Android Web view.
The slider work fine with Apple but doesn't load on Android WebView.
Can anyone help? www.pgc-usa.net/ivynails
Thanks
I think I know. Web views in Android by default do not have JavaScript enabled. This is because there is someway it can do harm to the app. To enable it though it takes two lines
WebSettings webSettings = yourWebview.getSettings();
yourWebview.setJavaScriptEnabled(true);
You can also set it so that links that are clicked open in the web view. ( Otherwise they open in browser.) to add this you just add
yourWebview.setWebViewClient(new WebViewClient());
All that together will make it come to this:
WebView yourWebview = (WebView) findViewById(R.id.myWebview);
yourWebview.loadUrl("http://www.pgc-usa.net/ivynails");
WebSettings webSettings = yourWebviewgetSettings();
webSettings.setJavaScriptEnabled(true);
yourWebview.setWebViewClient(new WebViewClient());
You can find out more by visiting this page on the Android developer site by clicking this link.
I am trying to make an Android app display a website in a WebView, but only the website home page actually show content properly via the WebView, the other pages completely disregard the website styles and display content with a white background and blue default hyperlinks. I tested the same type of app on iOS and it works fine there. What can I do about it?
This is the method:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myWebView = (WebView) findViewById(R.id.webView);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.setWebViewClient(new WebViewClient());
myWebView.loadUrl("http://www.awesomestories.com");
}
Settings should be set. Tricks Like this:
WebSettings settings = webview.getSettings();
settings.setBuiltInZoomControls(true);
settings.setPluginState(PluginState.ON);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
If you have kept Single Column Setting in WebView remove it, it will work just perfect.
myWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
If you have not kept Single Column setting and still its not working, then check that you have enabled JavaScript or not, if not then enable it.
myWebView.getSettings().setJavaScriptEnabled(true);
Android WebView requires you to explicitly enable javascript.
Styles in the page may be loaded via javascript, and generally websites don't tend to work good without it, so enabling it is important and might solve your problem in addition to that.
myWebView.getSettings().setJavaScriptEnabled(true);
I'm unable to open you tube into my application's webview on android 2.3 but on android 4.1 it works properly
here is the code
openWebLinkWebView.getSettings().setJavaScriptEnabled(true);
openWebLinkWebView.getSettings().setBuiltInZoomControls(true);
openWebLinkWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
openWebLinkWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
openWebLinkWebView.getSettings().setAppCacheEnabled(false);
openWebLinkWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
openWebLinkWebView.getSettings().setLightTouchEnabled(false);
openWebLinkWebView.getSettings().setUseWideViewPort(true);
openWebLinkWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
openWebLinkWebView.getSettings().setPluginsEnabled (true);
openWebLinkWebView.getSettings().setSupportMultipleWindows(true);
openWebLinkWebView.getSettings().setPluginState(PluginState.ON);
openWebLinkWebView.loadUrl(url);
you can use this code in your YouTube video Activity class
WebView web=new WebView(MyYouTubeActivity.this);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("youtube_link");
setContentView(mWebView);
Yes i faced this issue before this is because the feature of android:hardwareAccelerated="true" is only available in API version greater or equal to 11 and in 4.1 it is by default enabled (you can enable/disable this in manifest at application level).
I had a problem like yours when playing on 2.3.3
The following worked for me.
webView = (WebView) findViewById(R.id.idWebView);
webView.setWebChromeClient(new WebChromeClient(){
});
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginsEnabled(true);
webView.getTouchables();
webView.setBackgroundColor(Color.parseColor("#00000000"));
String emdLink = "http://www.youtube.com/embed/" + video_code;
webView.loadUrl(emdLink);
Note: you should have embed + your video code.
Note also the above uses a deprecated call - in place of
webView.getSettings().setPluginsEnabled(true);
it should be better to use (untested):
webView.getSettings().setPluginState(PluginState.ON);
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.