/android-kotlin-webview

An Android WebView simply converted from Java to Kotlin using the basic Android Studio tool.

Primary LanguageKotlinApache License 2.0Apache-2.0

Android Kotlin WebView

API

Description

An Android WebView simply converted from Java to Kotlin using the basic Android Studio tool.

Table of Contents

Installation

  1. Clone the project;
  2. unzip the folder;
  3. run Android Studio;
  4. open a new project;
  5. and pick the package.

Usage

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 loadURLdirectly 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" />

Contributing

This sample is open to contributions; please, read Contributing guidelines before opening new issues or submitting pull requests to this repository.

Credits

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.

Screenshots

License

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.