Convert Website To Android App Using Android Studio

Convert Website To Android App Using Android Studio

Whether you are using WordPress or any other platform for your website, it is very easy to Convert a Website to Android App Using Android Studio with some basic code. It helps you to make a professional look of your online business in the field of mobile app.

Hi everyone, I am Saroj Meher, today I am going to discuss with you how to convert any website into a professional Android App.

Steps to Convert Website To Android App Using Android Studio

STEP 1 – Editing AndroidManifest.xml

Give Internet permission in AndroidManifest.xml file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app">
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

   <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Note: package=”com.example.app“> – change the domain name and application name.

STEP 2 – Editing styles.xml

open style.xml file from res >> values >> styles.xml

Now replace all the pre code with this given code —

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

STEP 3 – Editing activity_main.xml

Choose Android or Project >>App >>res >>layout >>activity_main.xml. Copy the code below and paste it in your xml file.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.app.MainActivity">

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

</RelativeLayout>

Note: In the line tools:context=”com.example.app.MainActivity” you need to put your domain name and app name.

STEP 4 – Editing MainActivity.java

Now move to the main codding part that is – MainActivity.java

Choose Android or Project >>App >>Java >>your app name >>MainActivity.java.

Paste the following code after the first line that is – package com.inspiritlive.application;

 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.webkit.WebSettings;
 import android.webkit.WebView;
 import android.webkit.WebViewClient;

 public class MainActivity extends AppCompatActivity {
 private WebView mywebView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mywebView = (WebView) findViewById(R.id.webview);
    WebSettings webSettings= mywebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mywebView.loadUrl("https://example.com/");

// Line of Code for opening links in app
    mywebView.setWebViewClient(new WebViewClient());
    }

//Code For Back Button
    @Override
    public void onBackPressed(){
        if(webView.canGoBack()) {
            webView.goBack();
        }
        else{
            super.onBackPressed();
        }
    }

}

NOTE: Replace the URL (example.com) with your Domain Name. Use https always as non-http is not supported in the android app.

FAQ on Convert Website To Android App Using Android Studio

How do I make an APK file from a website?

After doing all the above work, now your app is ready to build an APK file for your android app. In order to build an APK file, Go to – Build Menu – Generate Signed Bundle / APK. You can also upload this file to the Google Play Store.

How do you turn a website into an android app?

I have already discuss the simple steps to build a web view app for your website. In this way, you can turn any type of website into an android app.

Can I convert PHP website to Android app?

Yes, you can convert PHP website into an android app with the above procedures.

2 thoughts on “Convert Website To Android App Using Android Studio”

  1. Nice article.
    I have a question. Android Studio does not work on low end computer, in that case, is it a good idea to use online builder that converts my website into android app?

    1. Yes, you can use any online app builder to create that, but the only demerit is that either you have to pay some penny or they will place some ads on your App.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.