Reputation: 11
Trying to create a very basic app that has a webview. The webview will load a webpage that uses some javascript to make Ajax calls and update itself every few seconds.
My Android app works fine, I can load my page and it works as expected on any Android version after 2.3.3. In 2.3.3 the page loads, basic javascript seems to work, but it will not load the data from the Ajax calls. I can open this page directly in browser on 2.3.3 and it loads fine with Ajax calls updating the web browser.
I noticed that this was added in API 11, Which looks like what I need, but since it did not exist before 11, is there anything that could help? Since it works in the stock browser I would think it should work in webview??
public void setAllowContentAccess (boolean allow) Since: API Level 11 Enable or disable content url access within WebView. Content url access allows WebView to >load content from a content provider installed in the system. The default is enabled.
Let me know, thanks
Here is the code I am using, the url is stored in a system preference.
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUserAgentString(preferences.getString("deviceID", null));
myWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
myWebView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
myWebView.clearCache(true);
String defaultURL = preferences.getString("url1", null);
myWebView.loadUrl(defaultURL);
B
Upvotes: 1
Views: 4903
Reputation: 793
addJavascriptInterface
is broken in 2.3.3 see this post: http://code.google.com/p/android/issues/detail?id=12987
Here is a quick way to fix it : http://quitenoteworthy.blogspot.com/2010/12/handling-android-23-webviews-broken.html
Upvotes: 1
Reputation: 5964
Have you enabled javascript on the webview?
myWebView.getSettings().setJavaScriptEnabled(true);
Upvotes: 1