Android code for webview

webview for loading website in android
android code for webview to prevent popup for browser

For internet connection we have to add android.permission.INTERNET in Manifest

Step 1:

Goto AndroidManifest.xml ->click on Permission tab

Step 2:

Click on Add.. button  and select Uses Permission

Step 3:

select android.permission.INTERNET

android.permission.INTERNET is used for using internet connection

Step 4:

Add webview to res -> layout -> activity_main.xml

        android:layout_alignParentTop="true" />

The webview id is webView1

Step 5:

Add below code for webview

WebView ourSite = (WebView) findViewById(;
ourSite.setWebViewClient(new WebViewClient());

ourSite variable is used to assigned webView1 

Import Header file

// For webview
import android.webkit.WebView;
// For WebViewClient
import android.webkit.WebViewClient;

Leave reply

Add your comments here

Back to Top