Load an External Web Site in a WebView on Android

In that tutorial, you are going to learn how to load an external web site into your Android application with Android Studio. To load an external web site into an Android Application, we are going to use the WebView component available in the Android SDK.

Image for post
Image for post
SSaurel’s Blog loaded in an Android App

Note that you can discover this tutorial in video on YouTube :

The first thing to do is to add the internet permission to the Android Manifest because we are going to load data from the network.

In the Java code of the Main Activity, we are going to create a new instance of the WebView object. We enable Javascript on this WebView instance and then, we set a WebViewClient object instance on the WebView.

To avoid some memory leaks with the WebView and its internal state, we don’t forget to call the destroy method of the WebView instance used in the onDestroy method of our Main Activity.

This gives us the following code :

Last step is to run your Android Application to enjoy the SSaurel’s Blog loaded in a WebView :

To discover more tutorials on Android development, you can subscribe to the SSaurel’s Channel on YouTube :

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store