Nowadays, android apps play an important role in business. So if you want to start a new business or want to expand it you must have an android app. Creating an android app is not much more difficult. You can hire someone for this or in your free time you can create your own app.

I am ALI HOSSAIN. I am freelancer since 2014. In this time I created 100s of website. Most of the client want to make a android app. So if they update their website it should also update on app. So recently I learned how to convert a website to an android app. No matter which type of your website is. May be it is WordPress, PHP or basic HTML you can convert it to an android app. Just one think you need and that is your website should mobile friendly.

Want to learn, how to convert a website to android app? If yes you can check my following video.

I hope you enjoyed the video. Now for practice you might need source code and for that reason you can use this source code. Actually on YouTube lots of people wants it to me. I also emailed so many source code. But You know its impossible to share source code to everyone. So I made it easy.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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=".MainActivity"
    tools:layout_editor_absoluteY="81dp">

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="0dp" />
</android.support.constraint.ConstraintLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.alihossain.alihossain">
    <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>

MainActivity.java

package com.alihossain.alihossain;

import android.support.v7.app.AppCompatActivity;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.webkit.WebChromeClient;
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();
        mywebView.loadUrl("http://www.alihossain.com");
        mywebView.setWebViewClient(new WebViewClient());
        webSettings.setJavaScriptEnabled(true);
    }

    public class myWebClient extends WebViewClient
    {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            view.loadUrl(url);
            return true;

        }
    }


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

strings.xml

<resources>
    <string name="app_name">AliHossain</string>
</resources>

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#9ED752</color>
    <color name="colorPrimaryDark">#9ED752</color>
    <color name="colorAccent">#9ED752</color>
</resources>

styles.xml

<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>

If you think my source code or work is useful, please share it to your social media, So other people can see this. Thanks for your time.

Avatar
Published by Ali Hossain

View All Post by

9 thoughts on “How to convert a website to Android App

    1. shovo654 shovo654 says:

      You are welcome.

  1. Avatar Vikas Kumar says:

    This article is very useful. am use this coading and create my own android apk. thanks

  2. Avatar louie ann says:

    hi I have a problem..
    Webpage not available
    net:: ERR_CLEARTEXT_NOT_PERMITTED

    What is that sir?
    The data and wifi is open..

    I dont know where is the prob. because I saw the output in emulator but no website ..

  3. Avatar tpantara says:

    Thank you sir, I have some question about “splashactivity.java” sir, when I type the

    new Handler() –> The Handler is shown RED color sir. Could you please advise to resolve this?

    Once again, thank you very much sir

    1. Ali Hossain Ali Hossain says:

      It will fix when you import it. Check the video again. Thank.

  4. Avatar aadhar says:

    Thanks for this information, it’s really helpful for me.

  5. Avatar Rupesh says:

    very nice brother i have also created app for my website. but can can you give me some idea for the user can save page content offline in app.

  6. Avatar Frank says:

    can you make a video of how to import the codes please sir. Thank you

Leave a Reply

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.