Convert Website To Android Application Using Android Studio

Convert Website To Android Application

Today, I will Tell You How To convert Website to Android application using the Android Studio. You can also convert any website into the Android application by following this method. Therefore, you need an android studio to make the Android mobile application. We will use the Webview method in our java main activity to view the web into the android application. You can Also Watch My YouTube Video How To Convert Any Website Using Android Studio

Android Studio To Convert a Website Into App

First of all, You need an android studio to make the application. If you don’t have the android studio, So please download and install it on your computer. Open your android studio and click on the new project.

covert website to android application

Click on the Next button and select the empty activity. Now, Your empty project is open in the android studio.

Step: 1  AndroidManifest.xml:

Now, you will see the Manifest folder at the top of the left side in the android studio.  Open manifest folder >androidmanifest.xml. There you need to put the following codes, copy and paste

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

Seems like given screenshot

internet permission in android manifest
 

Step: 2    activity_main.xml in the android studio:

Secondly, We will change our activity_ main.xml file code. Therefore, we need to change all code of our XML file. So, Please remove the whole code and paste the following code into your XML file. Additionally, the following code will work only with your MainActivity.java. Therefore, Fill up your own java MainActivity.java path. Like this

tools:context=”com.computerandmobile.computetandmobileapp.MainActivity”>
activity_main.xml code:

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"  
tools:context=""> <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" android:visibility="gone" /> 
<ProgressBar 
android:id="@+id/progressBar1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_centerInParent="true" /> 
</RelativeLayout>

Step: 3  MainActivity.java  in Android Studio

Finally, this our last step to complete our android mobile app project. So, please change all MainActivity.java else to your package name. So, Please Copy and paste the following codes into MainActivity.java after your package name. Additionally, Don’t forget to change the domain name

MainActivity.java : 

import android.content.Intent;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    String ShowOrHideWebViewInitialUse = "show";
    private WebView webview ;
    private ProgressBar spinner;

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

        webview =(WebView)findViewById(R.id.webView);
        spinner = (ProgressBar)findViewById(R.id.progressBar1);
        webview.setWebViewClient(new CustomWebViewClient());

        webview.getSettings().setJavaScriptEnabled(true);
        webview.getSettings().setDomStorageEnabled(true);
        webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
        webview.loadUrl("https://www.computerandmobile.com");

    }

    // This allows for a splash screen
    // (and hide elements once the page loads)
    private class CustomWebViewClient extends WebViewClient {

        @Override
        public void onPageStarted(WebView webview, String url, Bitmap favicon) {

            // only make it invisible the FIRST time the app is run
            if (ShowOrHideWebViewInitialUse.equals("show")) {
                webview.setVisibility(webview.INVISIBLE);
            }
        }

        @Override
        public void onPageFinished(WebView view, String url) {

            ShowOrHideWebViewInitialUse = "hide";
            spinner.setVisibility(View.GONE);

            view.setVisibility(webview.VISIBLE);
            super.onPageFinished(view, url);

        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            switch (keyCode) {
                case KeyEvent.KEYCODE_BACK:
                    if (webview.canGoBack()) {
                        webview.goBack();
                    } else {
                        finish();
                    }
                    return true;
            }

        }
        return super.onKeyDown(keyCode, event);
    }
}

Therefore, The screenshot is given below.                                                                                    

mainactivity-java for web convert to application

Dependency In Build grade (module app ) to Convert Website

In, Finally, you need to add the following dependency into the Build. Grade (Module: app) in the dependencies section.

implementation  'com.android.support:support-annotations:28.0.0'

So, Friends our project how to convert the web into android mobile application completed. Therefore, go to the build option in the android studio and build your app and install it on your mobile, Because some time app does not work properly on an android emulator due to the google respiratory.

In conclusion:

Finally, Friends if you are facing any problem, please comment. We will try to give your response within 2  business days

3 thoughts on “Convert Website To Android Application Using Android Studio”

  1. Hey there! This is kind of off topic but I need some help from an established blog.
    Is it tough to set up your own blog? I’m not very techincal but I can figure things out pretty quick.
    I’m thinking about creating my own but I’m not sure where to start.
    Do you have any tips or suggestions? Appreciate it

  2. I think you need to create a free website using free domain and free hosting for your best practice if you have enough knowledge about how to make a website then buy a domain from GoDaddy and purchase cloud hosting from Hostgator by using promo code with 85% discount offer. Choose WordPress as cms.

Comments are closed.