Android – WebView

Today in this tutorial we learn how to implement webviewer application in Android Studio. We all know that webview application very helpful for our any website because we convert our website into an android application. So we will create webview application in very few simple steps:-
Step 1
First of all go to your Android Studio and create an empty android project name it WebView. Fill our required field and click next button. See as below picture:-
w1 e1594982987963
Step 2
Now go to AndroidManifest.xml file for give internet permission. Because without giving internet permission we can't access our application.
<uses-permission android:name="android.permission.INTERNET" />
Step 3
In next step go to app/res/layout and open activity_main.xml file and modify with below webview code.
<LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:custom="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
     tools:context=".MainActivity">

<WebView
    android:id="@+id/webView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

</LinearLayout>
Step 4
Now go to open MainActivity.java class and modify these below code for onCreate method.
public class MainActivity extends AppCompatActivity
{

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        WebView myWebView = (WebView) findViewById(R.id.webView);
        myWebView.loadUrl("http://www.google.com");
        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        myWebView.setWebViewClient(new WebViewClient());

    }
}
Step 5
Finally our application ready to debug. Run the application and choose a running android device and install the application on it and verify the results.
webview