How to make an Android WebView Application?

How to make an Android WebView Application?

Android WebView is one of the method to build Website or Web Application into Android Install able (APK) File. Because of it you could not need to open browser to access the Website or Application.

Step-by-Step

Step 1: Create Empty Activity on Android Studio

Step 2: Place WebView in ( activity_main.xml )

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

Step 3: MainActivity

Step 4: Code for Back Press Button

Full Code of MainActivity

public class MainActivity extends AppCompatActivity {
    private WebView YourWebView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        YourWebView = (WebView) findViewById(R.id.webview);
        WebSettings webSettings = YourWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        YourWebView.loadUrl("https://naulowiring.herokuapp.com/");
        YourWebView.setWebViewClient(new WebViewClient());


    }

    @Override
    public void onBackPressed()
    {
        if(YourWebView.canGoBack())
        {
            YourWebView.goBack();
        }
        else
        {
            super.onBackPressed();
        }
    }

}

Step 5: Don’t Forget for Internet Permission ( AndroidManifest.xml )

Output looks like this

Step 6: Remove Title from Application

Goto Styles.xml and change it.

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">

After Changing the line your app have no title and look like this




Copyright © 2020-2021 Engineer Jagat All rights reserved. Developed by Ravindra Rana