Android Basics – A closer look at the Relative Layout

In this Article you will Learn about the Relative Layout.

In the last post you saw how Android provides us with three Layout options – Relative, Linear and Grid.

Relative Layout will help you to position the UI components relative to the Parent or other UI elements.

In the following Video you will learn how to use this Layout.

Source Code :

Android Basics – Learn about Relative, Linear and Grid Layouts

In this Post you will learn the basics of using Layouts. Layouts enable you to position the UI elements on the App Screens.

You can refer to the image and the video to understand the concept better.

You can use three types of Layouts

Relative Layout

Use this Layout to position the UI elements relative to each other.

Continue reading “Android Basics – Learn about Relative, Linear and Grid Layouts”

Android Basics – What is the Activity Lifecycle

Android Activity follows a Lifecycle from its time of creation till it gets destroyed. In this Article you will Learn about the Lifecycle.

As you can see in the attached diagram an Activity starts when its Launched. That’s the time its Constructor is run and object is created.

This is followed by the onCreate method which is responsible for Screen setup.

Continue reading “Android Basics – What is the Activity Lifecycle”

Android Basics – Using Handler and Runnable to Schedule Code

You will Learn about

  • Handler
  • post method
  • postDelayed method
  • Main Thread

Android runs every App in a separate Process for Security and Scalability.

So when you Run your App Android starts a Thread for the same.

A New Thread

Now if you want to run code which needs to run in the background then its recommended to use a separate thread for doing that.

This will not only improve user experience but also prevent delays and crashes.

Continue reading “Android Basics – Using Handler and Runnable to Schedule Code”

Android Studio 2 – Code change deployment in Real time, a Revamped Emulator and More

Android Studio 2 has introduced some great improvements. As an Android Developer you will appreciate the improvements introduced.

Some WOW Features

Instant Run

With this feature your code changes will be deployed in Real Time. A Full Build might not be required.

Improved Emulator

Running the new Emulator is faster than using the real device. Wow !!

The Emulator has a tool box now to enable features like screen rotation, screenshots and more. It uses SMP Support.

GPU Profiler

Now on IntelliJ 15

Offers improved Stability and lot of improvements.

The Studio also improves the build and deploy cycle process.

The Beta is now available for download.

Android Basics – Run your App on your Android Phone

Time to run your App on the Mobile Device. I have provided the Steps, Screenshots and a Video to help you with this.

You can refer to the Images and the Video to get your App up and running on your Mobile Phone.

Android Basics – Call an Activity in another App using Implicit Intent

It is possible to call an Activity in another App from your App by using an Implicit Intent.

In the last Article you saw how to use an Explicit intent to call an Activity in
the same App.

A Scenario can be if you want to send a Text Message when the user clicks on a Button in your App.

To achieve this you need to know a few basic concepts:

1. Action

In an Explicit Intent you need to specify the Action – like Email, Message, Call – basically what kind of Intents you want to use.

Continue reading “Android Basics – Call an Activity in another App using Implicit Intent”

Android Basics – What is an Intent and how is it used to call an Activity ?

In Android App you can have multiple Activities. Each Activity performs a certain task. At times it needs to call another Activity.

To do this Intent is used. Which means an intent to do something.

To call a new MessageActivity from the MainActivity – on click of a Button add the following two lines in your MainActivity

Intent intent=new Intent(this, MessageActivity.class);

That’s it !

Android Basics – How to use findViewById method

If you want to reference any UI component, defined in the Layout XML file, then you need to use the findViewById method.

In your Activity class add the following code snippet

TextView helloText = (TextView) findViewById(;
if(helloText != null){
Log.v(TAG, “Lets check the value in hello id “+helloText.getText());

Once you get a reference you can perform operations on the element.


Android Basics – Add a Button and display a Toast on click

Time for some Action. Let’s add a Button to the Layout XML file and on click of button let’s display a message to the user.

Simple Steps

Add a Button component to the XML file.

    android:text="Click Me"

Add a method to the MainActivity class.

public void clickMe(View view){
    Toast.makeText(MainActivity.this, "Button Clicked !!", Toast.LENGTH_SHORT).show();

You are all set. Test your app now.

Source Code