I am trying to load a website in my android app using webview, but the webview does is not rendering the website.
The website is https://www.rbsdigital.com/
The webview that I'm using is from this github project .
The logs that I get is:
10-12 19:57:14.188 1041-1041/com.teknorial.webviewapp I/chromium: [INFO:CONSOLE(0)] "'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.", source: (0)
10-12 19:57:14.189 1041-1041/com.teknorial.webviewapp I/chromium: [INFO:CONSOLE(0)] "'webkitIndexedDB' is deprecated. Please use 'indexedDB' instead.", source: (0)
Here's my code. From the github project.
private WebView view;
private static final String RBS_URL = "https://www.rbsdigital.com/";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.setWebViewClient(new MyBrowser());
view.getSettings().setLoadWithOverviewMode(true);
view.getSettings().setUseWideViewPort(true);
view.setWebChromeClient(new WebChromeClient());
view.loadUrl(RBS_URL);
}
private class MyBrowser extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
Now if I use the default webview like the one from this.
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("https://www.rbsdigital.com/");
The app loads the browser instead of rendering the website from the webview.
If Android webview does not support the website, is it possible to load this by any means?
try this line of code for getting rid of deprecated!
navigator.webkitTemporaryStorage.queryUsageAndQuota (
function(usedBytes, grantedBytes) {
console.log('we are using ', usedBytes, ' of ', grantedBytes, 'bytes');
},
function(e) { console.log('Error', e); });
read this answer
I hope it will work fine!
Related
I am trying to load http://www.bing.com or https://www.bing.com in web view but it is not loading. When I debug I found that the onPageFinished() callback is executed and the web view is still blank.
I have tried with other websites such as http://www.google.com it works fine.
Here is my code
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
WebView webView = findViewById(R.id.web_view);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setDomStorageEnabled(true);
webView.setWebViewClient(new WebViewController());
webView.loadUrl("http://www.bing.com");
}
public class WebViewController extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
In the logs I'm getting the following message when I'm trying to load bing website
2020-04-10 17:41:31.981 6044-6044/com.mawinbet.android I/chromium: [INFO:CONSOLE(0)] "The resource http://www.bing.com/rb/2U/cj,nj/6BsKE-ZQeKe0vHb0vclH0k01aag.js?bu=BUBKDlVY was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.", source: (0)
Can you please tell me how to solve this problem.
I am trying to display https://plus.google.com/myprofilepage(ignore myprofilepage part I just made it up, in code its substituted with my actual profile page) page in my app within a webview. The problem is the app is not displaying anything, earlier I tried with just http://www.google.com and https://www.google.co.in and it worked.
There are no logs created, so could not get them. I do have internet connected and AndroidManifest.xml too has permission INTERNET.
I want the google plus page to be displayed in WebView is just my basic requirement, I think I am missing something that is required to load google plus. Can someone help.
targetsdkversion is 21.
Below is my code:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_about_developer, container, false);
//String url = getActivity().getResources().getString(R.string.about_page);
String url="https://plus.google.com";
WebView webView = (WebView) v.findViewById(R.id.devwebView);
webView.setWebViewClient(new WebviewHandler());
webView.setInitialScale(1);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(false);
webView.loadUrl(url);
return v;
}
private class WebviewHandler extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
#Override
public void onReceivedSslError(final WebView view, final SslErrorHandler handler, SslError error) {
handler.proceed();
}
}
Google+ uses a lot of javascript, enable it with webView.getSettings().setJavaScriptEnabled(true);. Worked for me
+1 to what Lamorak said. Enabling JavaScript is a must. This is the bare minimum of code that is required (besides having the INTERNET permission):
WebView webView = (WebView)findViewById(R.id.webView);
// This is to avoid "Open with..." dialog for the G+ page.
webView.setWebViewClient(new WebViewClient());
WebSettings settings = webView.getSettings();
// Enable JavaScript.
settings.setJavaScriptEnabled(true);
// The two lines below are to enable interpreting <meta viewport> tag.
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
webView.loadUrl("http://plus.google.com/...");
trying to load a simple web page in WebView as below
alway leads to the fact that the browser is being launched with it.
The following code I wrote in my main activity besinde defining
"uses-permission android:name="android.permission.INTERNET" "
in the manifest. There is no Exception thrown which I verified with the catch block.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
WebView myWebView = (WebView) findViewById(R.id.myWebView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("http://www.google.com");
} catch (Exception e) {
Log.e("MyApp", e.getMessage());
}
}
I cannot imagine what coult be simpler than my scenario. I guess as I do not do things like clicking a link
it is not necessary to do things like
// By default, redirects cause jump from WebView to default
// system browser. Overriding url loading allows the WebView
// to load the redirect into this screen.
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
Do you have any Idea what could go wrong here?
In my very first example I do not use setWebViewClient(... at all but also in that case the browser opens instead of loading the side into the web view.
Thanks and Regards
Dieter
By returning fase in shouldOverrideUrlLoading(), you're instructing the WebView to ignore loading the URL and open the device's default browser instead.
You'll want to replace the contents of that function with:
// By default, redirects cause jump from WebView to default
// system browser. Overriding url loading allows the WebView
// to load the redirect into this screen.
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
I am trying to Load a webview in Android. Where web page have a swf file but it is not loading. I know there are many question and answer on same topic but no one helped me.
I have already targeted it version 11. And I have put android:hardwareAccelerated="true" too in manifest.xml file.
My code is here-
public class MainActivity extends Activity {
private WebView mWebView;
String url="http://mypages.com/Ch_001/ScoPage.html";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.webView);
mWebView.setKeepScreenOn(true);
WebSettings settings = mWebView.getSettings();
settings.setPluginState(PluginState.ON);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.setInitialScale(100);
// wbView.getSettings().setUseWideViewPort(true);
mWebView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
mWebView.setWebViewClient(new MyWebViewClient());
}
private class MyWebViewClient extends WebViewClient {
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler,
SslError error) {
Log.e("Error VAGARO", error.toString());
handler.proceed();
}
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
}
}
After one week struggle I got a Flash player from Macromedia, which works for me.
You can search in Google for-"Flash Player 11.1.for Android 4.0 - Macromedia - Adobe" or install APK from this link.
Install this apk in your Android device.
And when you will open it, it will ask for choose default browser.
Choose any browser which support Flash (UC-Browser, Chrome etc).
Now run your any application it will load your Flash video.
Add this code:
webview.getSettings().setPluginsEnabled(true);
add mWebView.loadUrl(url);in onCreate
I have created a page which has link to a page of a website. So for showing that on I have used a WebView and it works fine.
My Problem is that when I click on any link given on that webpage, the link opens in phone's default browser view. But I want all the links to be opened in my created WebView.
Have I made any mistake or it is right..
Please Help Me
My code is as follows...
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Log.e("------------", ".........................................................................................");
setContentView(R.layout.terms_of_use_web_view_page);
btn_back = (Button) findViewById(R.id.terms_of_use_button_back);
btn_back.setOnClickListener(this);
webview = (WebView)findViewById(R.id.terms_of_use_webview);
webview.getSettings().setJavaScriptEnabled(false);
webview.loadUrl("http://www.oomphlink.com/terms-of-use/");
}
Try specifying your own WebViewClient:
WebView webView = (WebView)findViewById( R.id.terms_of_use_webview );
webView.setWebViewClient( new WebViewClient()
{
#Override
public boolean shouldOverrideUrlLoading( WebView view, String url )
{
view.loadUrl( url );
return true;
}
});
To further understand why this is necessary have a look at the documentation for the shouldOverrideUrlLoading method.
wv.setWebViewClient(new MyWebViewClient());
public class MyWebViewClient extends WebViewClient{
}
link for more info...