Android Tutorial Day 1

Learning Objective: Let’s start learning Android App Development from the scratch. I am going to explain all the concepts one by one and make you Pro Android Developer in a month or two. Let’s Start.


Few Important Terminology you need to understand before you start learning Android App Development.

Android Studio: Android Studio is used to develop android app. You can download android studio using Download Android Studio and install it on your computer.

Android SDK: SDK Stands for Software Developer Kit. Android SDK is collection of tools which required to build android application.

Android AVD: AVD Stands for Android Virtual Device. When you are developing android application you need to test your android app with some dummy device, to install dummy device on your computer you can try AVD. Popular AVD.

Java Language: Java Language Knowledge is required to build Android Application. In Android Application when you want to perform any kind of operations like on button click you want to move from one screen to another screen then this code can be written in Java Language. Learn Java

XML Language: XML Language is used in Layout Design for Android App. When you want to design your android application layout you need to use XML Language. Learn XML Language

Kotlin Language: Kotlin is new language used for Android App Development. If you don’t want to use Java Language for Android App Development you can use Kotlin Language. Learn Kotlin

Google Play Store: This is one of the first choice for all android phone users to download Android App and Games. In your android phone you open play store app to download any new android app. So as a Android App Developer you should know about Play Store Publish Console. To publish your app to Play store one time charges is of 25$ is applicable. You can upload unlimited app after creating account. If you wish to upload app to any other store here is Play Store Alternatives.


Activity: Activity means you see any screen on android application and you can interact with it, This means it is activity. Activity has 2 important elements to understand. 1. Layout and 2. Code Behind.

Service: Service is background activity happening in background. For example you are sharing your live location on WhatsApp with your friends. Once you started it your friend can see your realtime locations. This is example of Service. Service has mostly code behind file only.

Layout File: All android screen layout resides in res/layout folder. Layout can be for 1. Activity, 2. Fragment, 3. Sub Layout etc.

Code File: When you are performing any actions and Android App respond you with some or other options then this happens via Code Behind File.

Android Tutorial Day 2

Learning Objective: Hope you have understood the key terminology about Android App Development. Now Let’s Start using Android Studio and make our first Hello World Application.


Checklist before you start:

Android Studio Installation Done?

SDK Installation Done?

AVD Installation Done?


I am Ready to Start


Start Android Studio

Create New Project (Select Option Phone and Tablet) (Select Basic Activity)

Give Project Name, Package Name (This will be your URL when you publish app on play store), Location (Strickly Save to D:\AndroidCode Folder only) (Don’t use Folder name with Space) (Choose Language Java) Minimum SDK : Select 6.0 / 7.0)

Click on Finish to Create Sample Hello World Project for you.


Now you have following files ready:

In your Project > App > manifests > AndroidManifest.xml

In your Project > App > Java > FirstFragment, MainActivity, SecondFragment

In your Project > App > res > Layout > activity_main.xml, content_main.xml, fragment_first.xml, fragment_second.xml

In your Project > App > res > navigation > nav_graph.xml

Now Let’s discuss about all above files, This all files are most important to quick start with android app development.


Ohh… many other folders are also there..

App > res > drawable

App > res > menu

App > res > mipmap

App > res > values >

Gradle Scripts > build.gradle (Modules)


Is anything else i need to study as Beginner? Yes:

View > Tool Window > LogCat

File > Export > Export to Zip File

Build > Generate Signed APK


Now Run & See Hello World Application

Android Tutorial Day 3

Learning Objective: Hope you have succesfully run Hello World Application. Now Its time to understand it’s code structure and update code. Also we will make simple app with some code.


Question – 1 : How to find out Which Screen / Activity / Fragment is setup as Startup Screen?

Answer: First you need to check out your App > Manifests > AndroidManifest.xml file and look for Activity with <intent-filter> code and look for Launcher category options.

Check out that Activity Java Code > XML Code > You will find “nav_graph”

res > navigation > nav_graph.xml : here startup Fragment is setup


Question – 2: How to Add new Fragment?

Answer: Right Click on App > New > Fragment > Blank Fragment. It will create create 2 new files. 1 Java File and 1 XML File.


Question – 3: In Fragment Java file I want to add code to move from one fragment to another fragment, But where should I add my code?

Answer: In Fragment Java File you need to use OnCreateView method. Sample code is here:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.fragment_splash, container, false);

	final Handler handler = new Handler();
	handler.postDelayed(new Runnable() {
		@Override
		public void run() {

			NavHostFragment.findNavController(SplashFragment.this)
					.navigate(R.id.action_Splash_to_Login);
		}
	}, 5000);

	return view;
}

Now Let’s make one simple app with few screens and few layout options.

We need following:

SplashFragment

LoginFragment

Splash Fragment Layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    android:background="#03A9F4"
    tools:context=".SplashFragment">

    <!-- TODO: Update blank fragment layout -->
    <TextView
        android:textColor="#FFFFFF"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Welcome to Arth Technology" />

</LinearLayout>

Splash Fragment Java Code

package com.example.myapplication;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;

import android.os.CountDownTimer;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link SplashFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class SplashFragment extends Fragment {

    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    public SplashFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment SplashFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static SplashFragment newInstance(String param1, String param2) {
        SplashFragment fragment = new SplashFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_splash, container, false);

        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {

                NavHostFragment.findNavController(SplashFragment.this)
                        .navigate(R.id.action_Splash_to_Login);
            }
        }, 5000);

        return view;
    }
}

Login Fragment Layout Code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    android:background="#48D6D5D1"
    tools:context=".LoginFragment">

    <!-- TODO: Update blank fragment layout -->
    <TextView
        android:gravity="center_horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Login" />

    <EditText
        android:id="@+id/etusername"
        android:hint="Username"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <EditText
        android:id="@+id/etpassword"
        android:hint="Password"
        android:inputType="textPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <Button
        android:layout_gravity="center_horizontal"
        android:id="@+id/btnlogin"
        android:text="Login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <TextView
        android:id="@+id/tverrorlog"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="" />


</LinearLayout>

Login Fragment Java Code

package com.example.myapplication;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link LoginFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class LoginFragment extends Fragment {

    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    public LoginFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment LoginFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static LoginFragment newInstance(String param1, String param2) {
        LoginFragment fragment = new LoginFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_login, container, false);

        TextView tverrorlog = (TextView) view.findViewById(R.id.tverrorlog);
        EditText et1 = (EditText) view.findViewById(R.id.etusername);
        EditText et2 = (EditText) view.findViewById(R.id.etpassword);
        Button btn1 = (Button) view.findViewById(R.id.btnlogin);

        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if(et1.getText().toString().equals("admin") && et2.getText().toString().equals("admin"))
                {
                    tverrorlog.setText("Success");
                }
                else
                {
                    tverrorlog.setText("Invalid Username or Password");
                }
            }
        });


        // Inflate the layout for this fragment
        return view;
    }
}