All TalkersCode Topics

Follow TalkersCode On Social Media - A Social Media Network for developers Join Now ➔

WebView Not Loading URL Android

Last Updated : Mar 11, 2024

WebView Not Loading URL Android

In this article we will show you the solution of WebView not loading URL android, WebView can be used to serve a web application (or merely a web page) as a component of a client application.

A web page can be displayed as part of your activity layout using the WebView class, which is an extension to Android's View class.

It lacks elements seen in a fully functional web browser, like navigation controls and an address bar.

By default, WebView just displays web pages. When you want to include content that you might need to update in your app, for instance an end-user agreement or even a user guide, using WebView is frequently advantageous.

To display your content that is hosted online, you can build an Activity inside of your Android app that includes a WebView.

If your programme gives the user access to data that must always be retrieved from the Internet, like email, WebView can be useful in this situation.

In this situation, creating a WebView inside your Android app that displays the web page filled with user data may be simpler than making a network request, analyzing the response, and then rendering the data in an Android layout.

Step By Step Guide On WebView Not Loading URL Android :-

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""
      android:textSize="24sp" />
      android:layout_below="@id/textView" />
      android:text="Load URL" />


import android.os.Bundle
import android.view.View
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
class MainActivity : AppCompatActivity() {
   private var webView: WebView? = null
      private var textView: TextView? = null
      private var btnLoad: Button? = null
      override fun onCreate(savedInstanceState: Bundle?) {
         textView = findViewById(;
         btnLoad = findViewById(;
         webView = findViewById(;
         webView!!.webViewClient = WebViewClient()
         btnLoad!!.setOnClickListener(View.OnClickListener {
            webView!!.webViewClient = object : WebViewClient() {
               override fun onPageFinished(view: WebView, weburl: String) {
                  Toast.makeText(this@MainActivity, "Your WebView is Loaded....",
            webView!!.webChromeClient = object : WebChromeClient() {
               override fun onProgressChanged(view: WebView, newProgress: Int) {
                  textView!!.text = "Page loading : $newProgress%"
                  if (newProgress == 100) {
                     textView!!.text = "Page Loaded."

Android manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
<uses-permission android:name="android.permission.INTERNET" />
      <activity android:name=".MainActivity">
            <action android:name="android.intent.action.MAIN" >
            <category android:name="android.intent.category.LAUNCHER" />
  1. First we have to create an import function with the name
  2. Then we create a class with an activity.
  3. Then we create a private webview function.
  4. Then we create an override function.
  5. Then we create a public void as a bundle saved instance state.
  6. Then we create webview.load URL for the creation of link.

Conclusion :-

In the WebView, JavaScript is just by default turned off.With the WebSettings connected to your WebView, you can make it active.

Get WebSettings using the getSettings() method, and then turn on JavaScript using the setJavaScriptEnabled method().

I hope this article on WebView not loading URL android helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Ashish

Ashish is a dynamic and motivated individual with a passion of programming and an experienced programmer having 3+ years of experience in various languages like Java, Python, HTML, CSS, JavaScript, jQuery and various frameworks like Bootstrap

Follow Ashish On Linkedin 🡪