In my app, I show an external HTML site in either a CustomTabsIntent or a in a WebView:
if (customTabsIntent != null) customTabsIntent.launchUrl(this, Uri.parse("http://some.where.com/site.html"));
else startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://some.where.com/site.html")));
But the style of that HTML is already updated, but my smartphone shows the old style (old fonts etc.).
In the *.html file there is a *.css referenced:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href='https://my.site.com/assets/css/style.css' rel='stylesheet' type='text/css'>
</head>
And in that *.css file, there is an individual font referenced; e.g.:
@font-face {
font-family: 'MyFontRegular';
src: url('https://www.openfont.org/assets/mail/fonts/MyFontWeb-Regular.woff') format('woff'),
url('https://www.openfont.org/assets/mail/fonts/MyFontWeb-Regular.eot') format('embedded-opentype');
}
As I said, the chrome browser in my smartphone does not show the referenced fonts, because it cuts the http:// or https:// off. When I prepend that scheme manually into the address bar, the proper style is being shown.
How can I force the https:// scheme in the address field in my android browser, when it was called from my android app ?
It could be cache. If you have control over the html site, change the include to something like:
<link href='https://my.site.com/assets/css/style.css?something=132545' rel='stylesheet' type='text/css'>
After that, try it on the phone. If the cache clears up and pulls the new css file, change the number to a random generated number.
It will load the file each time the "something" variable changes. If you perform those style updates not so often, make it a fixed number, and keep increasing it each time you update the css file.
Following your information on the fonts not being loaded with https, you could try to override the onReceivedSslError and see it solves the problem:
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler,
SslError error) {
handler.proceed();
}
Be careful, this completely disables ssl validation... it´s a dangerous route.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With