Convert your website into an Android App

 Converting a website or blog into ab Android Application is one of the way to promote your website and reach out to more people. It also helps you to make people get updated with the changes and updates of your websites. If you convert your website or blog into an Android App, you can upload it on Google Playstore and a lot of people will see and possibly download it. For your blog or website to display well, it must be mobile friendly and responsive. Let’s convert this blog into an Android Application If you have read my previous posts, you will be familiar with most of the things I will be saying. If you are not familiar, you can spare some little time to go through my posts. Create a new project on Android Studio Since we want a full screen Application, we will remove the Action bar. Navigate to styles.xml in your res folder and edit the style Just change the DarkActionBar to NoActionBar

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

Navigate to the manifest.xml and add the internet permission, if you don’t add this permission you App won’t display because it can’t access the internet.
Add this above the <application></application>

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

Navigate to the activity_main.xml in the layout folder and add this following lines of code to display the website or blog

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
<!--This view is responsible for the display fo your website or blog-->
    <WebView
        android:id="@+id/webby"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />

</FrameLayout>

Navigate to the MainActivity.java and add this following lines of code

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

public class MainActivity extends AppCompatActivity {

    //Strore the URL of the website inside a String variable called      //url
    private String url = "https://wwww.rexandroid.blogspot.com";
    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //initialize the webview by calling findViewById
        webView = findViewById(R.id.webby);
        //get the web setiimgs
        //set for javascript containing site
        webView.getSettings().setJavaScriptEnabled(true);
        //responsible for opening links inside the app
        webView.setWebViewClient(new WebViewClient());
        //load the url of the blog you stored inside @url
        webView.loadUrl(url);
    }
//This prevent the App from closing when you press the back key to //go to the previous page
    @Override
    public void onBackPressed() {
        if (webView.canGoBack()) {
            webView.goBack();
        } else {
            super.onBackPressed();
        }
    }
}

If you wanna add some other functionality to your App like progress bar etc., feel free to do so.
If you need any help, feel free to drop your comment in the comment box.

4 comments:

paridhi jain said...

Hello,,

Very nice information you provide.In this blog the complete information about how to Convert our website into an Android App. Also knowledgable information to make website mobile friendly and responsive.

Thanks and Regards
paridhi

Robert said...

Thanks for sharing such valuable information I am also impressed by the creativity of the writer. This is
excellent information. It is amazing and wonderful to visit your site. how can your website be converted into a selling "

Anonymous said...

Hello,
The information provide by you is very useful for me.I get knowledge that how to develop and grow my business.
Thanks and Regards

Paridhi jain

Anonymous said...

Online training and short courses are a great way to learn and advance in career and I think more people should move towards it