Published: June 13, 2020
This simple Android Studio Series Tutorial on How to load an URL inside a WebView using Android Kotlin. Just follow and copy the code below.
<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android = "http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_heigh="match_parent" tools:context=".WebViewTutorial"> <WebView android:id="@+id/webView" android:layout_width="match_parent" android:layout_width="match_parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="parent" app:layout_constraintEnd_toStartOf="parent"/> </androidx.constraintlayout.widget.ConstraintLayout>
override fun onCreate (savedInstanceState: Bundle?) { final.onCreate(savedInstanceState) setContentView(R.layout.activity_web_view_tutorial) webView.settings.javaScriptEnable = true webview.webViewClient = WebViewClient() webview.loadUrl(https://www.google.com) }
Important to insert this permission to enabled to access internet of the mobile app
<uses-permission android: name ="android.permission.INTERNET"/>
You can Download the source on GitHub and Follow the full video tutorial on YouTube. Don't forget to subscribe to the YouTube channel for more updates.
I will post again on this site and upload on YouTube about my next tutorial. Stay tune up and follow my other social media platforms for more updates.