

The complete code of the MainActivity. OklWebView=(WebView)findViewById(R.id.oklWebView) Īfter initializing the webview, we simply load the URL. Now, inside the onCreatemethod, we initialize the WebView as shown below.

Next, we create the object of WebView class inside MainActivity class as shown below: //creating object of WebView This is the main part to add webview in our app, first, we open the MainActivity.java file and import some basic classes as shown below import


In the above code, we have added the default web view in our Android Activity. Now go to app -> res -> layout -> activity_main.xml and add Webview, now our activity_main.xml file will look like as shown below: Step 3: Adding WebView to Android Activity Remember that you need set the write to external storage. Carefully follow my steps to create Web view Android Application, using Android Studio and I have included the source code given below. Now go to app -> mainfests-> AndroidManifest.xml and add internet permission, now our AndroidManifest.xml file will look like as shown below: This code is for Android webview, just paste it below in the oncreate method of webview activity. Now, wait for the project to finish building. Next click on the Finish button after filling in the above details. Open Your Android Studio Click on " Start a new Android Studio project"(Learn how to set up Android Studio and create your first Android project)Ĭhoose " Empty Activity" from the project template window and click on Next.Įnter the App Name, Package name, save location, language( Java/ Kotlin, we will use Java for this tutorial), and the minimum SDK(we are using API 19: Android 4.4 (KitKat)) Here, we will learn to add an Android WebView in our android app.
