How to Convert a Website into Android Application using Android Studio




In this tutorial we will learn How to Convert a Website into Android Application using Android Studio

So lets create a project.

Step 1 – Create new Android project.

Provide Activity name as EasyOnlineConverter

Step 2 – Add an webView to your activity as shown in the picture below.

Convert website to android app Design

layout/activity_main.xml

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

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

src/main/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.programmingknowledge.easyonlineconverter" >
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <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.example.programmingknowledge.easyonlineconverter;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class MainActivity extends ActionBarActivity {
    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("http://www.easyonlineconverter.com");
        myWebView.setWebViewClient(new WebViewClient());
    }

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

menu/menu_main.xml

<menu 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" tools:context=".MainActivity">
    <item android:id="@+id/action_settings" android:title="@string/action_settings"
        android:orderInCategory="100" app:showAsAction="never" />
</menu>

OUTPUT

Now run your android app, and you will see the following result

Convert website to android app
Click the button below to Download Source code

Download Source Code


Video Instructions


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





41 Comments

  1. Thank you. It was very helpful. how can we view In Desktop view from the android app.. now it is automatically changed to mobile version when we access the URL from app

  2. These Errors Took Place While Creating APK :

    Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]
    C:UsersuserDesktopandroid projectCrimeHack2appsrcmainjavacomexampleusercrimehackMainActivity.java
    Error:(4, 37) error: package android.support.design.widget does not exist
    Error:(5, 37) error: package android.support.design.widget does not exist
    Error:(42, 36) error: cannot find symbol variable menu
    Error:(54, 23) error: cannot find symbol variable action_settings
    Error:Execution failed for task ‘:app:compileDebugJavaWithJavac’.
    > Compilation failed; see the compiler error output for details.
    Information:BUILD FAILED
    Information:Total time: 39.347 secs
    Information:5 errors
    Information:0 warnings
    Information:See complete output in console

  3. Error:Failed to capture snapshot of output files for task ‘transformClassesWithDexForDebug’ property ‘streamOutputFolder’ during up-to-date check.
    > Failed to create MD5 hash for file ‘C:UsersAdminAndroidStudioProjectsEasyOnlineConverterappbuildintermediatestransformsdexdebugfolders10005slice_8classes.dex’.

    What type of this issue? How to resolve?

  4. many issues mostly appcompact library issue. Could you start wiith install, SDK to be installed & library dependencies ????

  5. hi thank you for your guide it was really helpful.
    I have a question and I be glade if you can help me.
    I convert a website that have a login screen how can I auto fill this fields and submit ?

  6. i just created an app as told to convert web to app. and created my first ever APK file and run in my phone.
    Only problem till now I found out that is when i click shopping cart in Website it says “the item being added to your shopping cart. However, in the app it does not show that popup though it adds the item in my shopping cart.
    What should i do? What changes I need to make in my App.
    Also I would like to change the APP Icon that is should show the Icon I want for my APP in the mobile. What do i need to do to change that icon?

  7. Is it possible to update the android app. if it is possible, how can it be done since it was a website that was converted into an apk file. thanks

  8. The version of Android Studio I downloaded appears to be an updated one, and a number of things are different. When I attempted to paste the code in the appropriate sections, it does not run the app, and gives errors at different points. Is there an updated version of the instructions?

Leave a Reply

Your email address will not be published.


*