Android Question Webview display different from browser

Keith Yong

Active Member
Licensed User
Longtime User
Hi,

May I know know why it show different from Webview? Following is the link, appreciate if you could let me know what is the problem.

B4X:
WebView1.LoadURL(Common.WebLink)

http://mysigntouch.thersgc.com/weather.php

a8a10c6f-3f6c-4101-94fe-e9b508f255ed.jpg
c7a8cfcd-dec2-4703-9777-a0a7da85e01d.jpg
 

Keith Yong

Active Member
Licensed User
Longtime User
Your link is not responsive. The contents remain static even if you adjust the screen size

But when I open it at the browser in the phone, it show nicely. I try it at WebView B4I, it work perfect also. The problem only happen in B4a Webview.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Try adding the chrome client to webview as explained in tip #1 in my below signature:
 
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime User
Try adding the chrome client to webview as explained in tip #1 in my below signature:


B4X:
'    'WVExtras 1.40
'    Dim WebViewExtras1 As WebViewExtras
'    WebViewExtras1.addWebChromeClient(WebView1, "WebViewExtras1")
'    WebView1.LoadURL(Common.WebLink)

    
    'WVExtras 2.20   
    Dim WebViewExtras1 As WebViewExtras
    WebViewExtras1.Initialize(WebView1)
    
    Dim WebChromeClient1 As DefaultWebChromeClient
    WebChromeClient1.Initialize("WebChromeClient1")
    WebViewExtras1.SetWebChromeClient(WebChromeClient1)
    
    Dim WebViewClient1 As DefaultWebViewClient
    WebViewClient1.Initialize("WebViewClient1")
    WebViewExtras1.SetWebViewClient(WebViewClient1)
    
    WebViewExtras1.LoadUrl(Common.WebLink)

I have added WebViewExtras 1.4 and 2.20 to try, but it still having the same problem. You can try with the following URL. It show nicely in browser in the phone and B4I WebView, but not in B4a WebView.

http://mysigntouch.thersgc.com/weather.php
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Using webview extras and webview settings, there are a lot of different options to try (like overview mode on or off).

You might need to try all the different combinations to see if you can get it to look the same.

Also, try adding this modification to the manifest to allow non-SSL connections - maybe some resource in that page needs a non-ssl connection and it's failing because this manifest mod is missing:

 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
yes; you need to use a browser (eg, chrome), not a webview. a webview is not a complete browser.

here is a quote from google's webview documentation:
B4X:
WebView objects allow you to display web content as part of your activity layout, but lack some of the features of fully-developed browsers.
found here

i hope this answers your question.
 

Attachments

  • chrome.png
    chrome.png
    216.3 KB · Views: 234
  • webview.png
    webview.png
    210.5 KB · Views: 210
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime User
yes; you need to use a browser (eg, chrome), not a webview. a webview is not a complete browser.

here is a quote from google's webview documentation:
B4X:
WebView objects allow you to display web content as part of your activity layout, but lack some of the features of fully-developed browsers.
found here

i hope this answers your question.

But it works fine in B4I WebView.
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
1. Most iphones have higher resolutions than android phones hence it displaying ok on iphones. When you open the page in desktop browser and you resize the browser, you will see that overlap, so to me it has nothing to do with webview.

I will once again stress on my post #2.

If your webpage is responsive, it will display well on all devices. Check your code

EDIT: 2. The webpage is a simple one, you can use imageview and labels to create that layout with proper anchors, and use minihtmlparser to get the values from the link to display - open if it's your own server, create some form of JSON and get it with okhttputils2
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
But it works fine in B4I WebView.
then use an iphone. android uses google's implementation, which by its own definition, is an incomplete browser.
 
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime User
1. Most iphones have higher resolutions than android phones hence it displaying ok on iphones. When you open the page in desktop browser and you resize the browser, you will see that overlap, so to me it has nothing to do with webview.

I will once again stress on my post #2.

If your webpage is responsive, it will display well on all devices. Check your code

EDIT: 2. The webpage is a simple one, you can use imageview and labels to create that layout with proper anchors, and use minihtmlparser to get the values from the link to display - open if it's your own server, create some form of JSON and get it with okhttputils2
The Webpage is not belong to me. Is ok, since can't do anything, I will use browser instead of WebView. Thanks
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
actually, it will work. see here
you need to add some inline java. i just tried it. it works. sorry about telling you it wouldn't. the fact still remains that a webview cannot do everything a full browser does. and apple's implementation is not necessarily the same as google's. they create the webview, not b4x
 

Attachments

  • webview.png
    webview.png
    214.2 KB · Views: 215
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime User
actually, it will work. see here
you need to add some inline java. i just tried it. it works. sorry about telling you it wouldn't. the fact still remains that a webview cannot do everything a full browser does. and apple's implementation is not necessarily the same as google's. they create the webview, not b4x
The link given was showing the image into Webview, not using URL.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
  • Like
Reactions: eps
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
it's in post #1 in the link i referred to here
B4X:
#if B4A
#if Java
public void zoom(android.webkit.WebView wv) {
   wv.getSettings().setUseWideViewPort(true);
   wv.setInitialScale(1);
}
#End If
#End If

you call the inline java with a java object from b4a, as in the post. look at it carefully. after you set that up, you load your webview and it appears just like chrome (and desktop) show the paqe
 
  • Like
Reactions: eps
Upvote 0

Keith Yong

Active Member
Licensed User
Longtime User
it's in post #1 in the link i referred to here
B4X:
#if B4A
#if Java
public void zoom(android.webkit.WebView wv) {
   wv.getSettings().setUseWideViewPort(true);
   wv.setInitialScale(1);
}
#End If
#End If

you call the inline java with a java object from b4a, as in the post. look at it carefully. after you set that up, you load your webview and it appears just like chrome (and desktop) show the paqe
I got it now. Thanks for your help. Really appreciate
 
Upvote 0
Top