A
A
Alex2021-01-31 21:09:05
Java
Alex, 2021-01-31 21:09:05

How to teach WebView to accept url address without http\https and www?

I was surprised by the loadUrl function in WebView, which cannot load sites without specifying the protocol and www. The same CEF in C# itself substitutes the required protocol and loads the page.
How to implement such a function in Android Studio in Java with the selection of the necessary http or https protocol and, in general, the formation of the correct url from the usual "example.ru"?

targetSdkVersion 30

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-01-31
@vabka

Without www. - won't work, because it's part of the domain name (fortunately, most sites don't already have this)
Add http:// automatically to all urls that don't have a protocol.
If the site is normal, then it should redirect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question