In this tutorial, we will learn How to Convert a Website into an Android Application using Android Studio.
If you do not know anything about Android Studio yet, Don’t worry.
We will start everything from scratch.
This is how the website looks like:
And the Android app, we developed using Android Studio looks like:
Before we begin:
NOTE: If you downloaded Android Studio and already installed in your system then you can skip the part and Go to direct the coding part.
If not
Download Android Studio:
Google provides Android Studio for the Windows, Mac OS X, and Linux platforms. You can download this software from the Android Studio homepage.
Before downloading Android Studio, make sure your platform meets one of the following requirements:
Windows OS
Microsoft Windows 7/8/10 (32-bit or 64-bit)
2 GB RAM minimum, 8 GB RAM recommended
2 GB of available disk space minimum, 4 GB Recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)
1280 x 800 minimum screen resolution
For accelerated emulator: 64-bit operating system and Intel processor with support for Intel VT-x, Intel EM64T (Intel 64), and Execute Disable (XD) Bit functionality
Mac OS
Mac OS X 10.8.5 or higher, up to 10.11.4 (El Capitan)
2 GB RAM minimum, 8 GB RAM recommended
2 GB of available disk space minimum, 4 GB Recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)
1280 x 800 minimum screen resolution
JDK 6
Linux OS
GNOME or KDE desktop: Tested on Ubuntu 12.04, Precise Pangolin (64-bit distribution capable of running 32-bit applications)
64-bit distribution capable of running 32-bit applications
GNU C Library (glibc) 2.11 or later
2 GB RAM minimum, 8 GB RAM recommended
2 GB of available disk space minimum, 4 GB Recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)
1280 x 800 minimum screen resolution
JDK 8
For accelerated emulator: Intel processor with support for Intel VT-x, Intel EM64T (Intel 64), and Execute Disable (XD) Bit functionality, or AMD processor with support for AMD Virtualization (AMD-V)
Installing Android Studio on 64-bit Windows 8.1
To complete your installation, leave the Start Android Studio box checked and click Finish.
Running Android Studio
Android Studio presents a splash screen when it starts running:
If you’re like me and don’t have a previously installed version, you can just keep the default setting and click OK.
When you click Next, the setup wizard invites you to select an installation type for your SDK components. For now, I recommend you keep the default standard setting.
The wizard will download and unzip various components. Click Show Details if you want to see more information about the archives being downloaded and their contents.
Your options are to either put up with the slow emulator or use an Android device to speed up development. I’ll discuss the latter option later in the tutorial.
Finally, click Finish to complete the wizard. You should see the Welcome to Android Studio dialog box:
You’ve installed and configured Android Studio and created a project for your first Android Studio mobile app; now you’re ready to build your Android application. In Android Studio, this means populating your new project with Java source code and resource files.
Your first Android Studio mobile app
Starting a new project
From our setup so far, you should still have Android Studio running with the Welcome to Android Studio dialog box. From here, click Start a new Android Studio project. Android Studio will respond with the Create New Project dialog box shown in Figure.
Click Next, and you will be given the opportunity to choose a template for your app’s main activity. For now, we’ll stick with Empty Activity. Select this template and click Next.
Next, you’ll customize the activity:
Enter W2A as the activity name and main as the layout name, and click Finish to complete this step. Android Studio will respond that it is creating the project, then take you to the project workspace.
The project window is organized into a tree whose main branches are App and Gradle Scripts. The App branch is further organized into manifests, java, and res subbranches:
- manifests stores AndroidManifest.xml, which is an XML file that describes the structure of an Android app. This file also records permission settings (where applicable) and other details about the app.
- java stores an app’s Java source files according to a package hierarchy, which is ca.javajeff.w2a in this example.
- res stores an app’s resource files, which are organized into drawable, layout, mipmap, and values subbranches:
- drawable: an initially empty location in which to store an app’s artwork
- layout: a location containing an app’s layout files; initially, main.xml(the main activity’s layout file) is stored here
- mipmap: a location containing various ic_launcher.png files that store launcher screen icons of different resolutions
- values: a location containing colors.xml, dimens.xml, strings.xml, and styles.xml
The Gradle Scripts branch identifies various .gradle (such as build.gradle) and .properties (such as local.properties) files that are used by the Gradle-based build system.
Now the coding part will start…
Add a webView to your activity as shown in the picture below.
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.vinaysomawat.careerhigh”
android:installLocation=”auto”
uses-permission android:name=”android.permission.INTERNET”/
application
android:allowBackup=”true”
android:icon=”@mipmap/faviconcircular”
android:label=”@string/app_name”
android:roundIcon=”@mipmap/faviconcircular”
android:supportsRtl=”true”
android:theme=”@style/AppTheme”
activity android:name=”.SplashActivity” android:theme=”@style/SplashTheme”
intent-filter
action android:name=”android.intent.action.MAIN” /
category android:name=”android.intent.category.LAUNCHER” /
/intent-filter
/activity
activity android:name=”.MainActivity” /
/application
/manifest
MainActivity.java
package com.vinaysomawat.careerhigh;
/**
* Created by Vinay Somawat on 10-01-2019.
*/
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(“https://careerhigh.in");
mywebview.setWebViewClient(new WebViewClient());
}
@Override
public void onBackPressed(){
if(mywebview.canGoBack()) {
mywebview.goBack();
} else
{
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
int id = item.getItemId();
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
values/styles.xml
resources
!-- Base application theme. --
style name="AppTheme" parent="Theme.AppCompat.Light"
!-- Customize your theme here. --
item name="colorPrimary"@color/colorPrimary/item
item name="colorPrimaryDark"@color/colorPrimaryDark/item
item name="colorAccent"@color/colorAccent/item
/style
style name="TextAppearance.AppCompat.Widget.ActionBar.Title" parent="android:TextAppearance"
item name="android:textColor"@color/titlecolour/item
item name="android:textSize"30sp/item
/style
/resources
values/strings.xml
?xml version="1.0" encoding="utf-8"?
resources
string name="app_name"CareerHigh/string
string name="hello_world"Hello world!/string
string name="action_settings"Settings/string
/resources
values/colors.xml
?xml version="1.0" encoding="utf-8"?
resources
color name="colorPrimary"#000000/color
color name="colorPrimaryDark"#303F9F/color
color name="colorAccent"#FF4081/color
color name="titlecolour"#398bb7/color
/resources
Add a launching activity to App: (It looks nice)

SplashActivity.java
package com.vinaysomawat.careerhigh;
/**
* Created by Vinay Somawat on 10-01-2019.
*/
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
}
And add some code it values/styles.xml
style name="SplashTheme" parent="Theme.AppCompat.NoActionBar"
item name="android:windowBackground"@drawable/background/item
/style
create a drawable/background.xml
file:
?xml version="1.0" encoding="utf-8"?
layer-list xmlns:android="http://schemas.android.com/apk/res/android"
item android:drawable="@color/colorPrimary" /
item
bitmap android:src="@drawable/logo2"
android:gravity="center" /
/item
/layer-list
make sure you add a sample image to drawable
folder to display in launching activity.
OUTPUT:
Now run your android app, and you will see the following result
Finally, your first Android App is created.
If you got stuck somewhere
Or use the following command:
command-line
And share your Android App with your friends.
Did I get something wrong? Mention it in the comments. I would love to improve.
If you learned even a thing or two, clap your hands ? as many times as you can to show your support!
Hello World, I am Vinay Somawat. A creative developer and a logical designer. You can find me on Linkedin or stalk me on GitHub or maybe follow me on Twitter? If that’s too social for you, just drop a mail to vinaysomawat40@gmail.com if you wish to talk tech with me.
Have a nice day!
Michael D J Paccione