How to Convert Any Website to Android App in Android Studio?

Here, we are going to make an application for the “GeeksForGeeks” website. By making this application we will be able to learn how we can convert a website to an Android Application just by following simple steps. You can use this concept for your personal website too and learn something new.



What we are going to build in this article? .


In this application, we will learn how we can use different portals of a website and show them as fragments in our android application. In this application three portals of the Geeksforgeeks website- Home, Practice and Contribute will be used as fragments in our application. So, you can see a live example to convert a website into an application. The concept of WebView is used to do this desired work. A sample video is given below to get an idea about what we are going to do in this article. We are going to implement this project using both Java and Kotlin Programming Language for Android.

Simple Steps to Convert Your Website into an Android Application:.

  • To add the logo of your application.
  • To add a splash screen to your application.
  • To use the Navigation drawer in our application so that, different portals of our website can be used as fragments in the navigation drawer.
  • To use a WebView so that, the web content can be accessed easily.
  • To use WebViewController class so that the content on the Website can be directly shown in the application rather than opening it in the browser.
  • To add a helpline activity.

  • And by following these steps you can convert your website to an application in the simplest way. So, let us see a step-by-step implementation to convert GeeksForGeeks Website into an application.


<WebView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/webView"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    tools:ignore="MissingConstraints" />


import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    String websiteURL = "https://coupon.technovedant.com/"; // sets web url
    private WebView webview;

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

        //Webview stuff
        webview = findViewById(R.id.webView);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.getSettings().setDomStorageEnabled(true);
        webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
        webview.loadUrl(websiteURL);
        webview.setWebViewClient(new WebViewClientDemo());

    }

    private class WebViewClientDemo extends WebViewClient {
        @Override
        //Keep webview in app when clicking links
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }

}


<uses-permission android:name="android.permission.INTERNET" />


Post a Comment

Previous Post Next Post