An Android WebView simply converted from Java to Kotlin using the basic Android Studio tool.
- Clone the project;
- unzip the folder;
- run Android Studio;
- open a new project;
- and pick the package.
Change the URL indirectly from strings.xml from:
<string name="website_domain">quaestio.org</string>
<string name="website_url">https://quaestio.org</string>
to:
<string name="website_domain">your.url</string>
<string name="website_url">http://your.url</string>
Or change the loadURL
directly in MainActivity.kt from:
21 mWebView.loadUrl(getString(R.string.website_url))
30 if (Uri.parse(url).host == getString(R.string.website_domain)) {
to:
21 mWebView.loadUrl("http://your.url")
30 if (Uri.parse(url).host == "your.url") {
And don't forget to edit the following lines in the AndroidManifest.xml file:
<data
android:host="quaestio.org"
android:scheme="https" />
This sample is open to contributions; please, read Contributing guidelines before opening new issues or submitting pull requests to this repository.
A live demo can be seen from Quaestio's web app which loads similar Android Kotlin WebView pieces of code.
A special thanks to Vamsi Tallapudi's Android Java WebView sample and CodeRefer's tutorials for the introductory lessons they provided in the past.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use files of this sample except in compliance with its License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied.
See the License for the specific language governing permissions and limitations under the License.