Introduction to Android, activities, intents, services, layouts

This tutorial will teach you some basics of Android, so you can make your first Android app easily.

 

Introduction to Android

Android is an operating system for a number of different devices like tablets and smartphones. It is based on Linux maintained by Google. Statistics shows that there are now 2 billion monthly active Android devices around the world. Android is powerful operating system with number of different features. Here are few of them

Messaging: It allows SMS and MMS.

Browsing: Android’s web browser is based on WebKit layout engine. It allows browsing.

User Interface: Android provides eye catching and easy to use user interface.

Touch screen input: Android supports simple and multi touch system.

3G communication protocol: It provides 3G, 4G and 5G communication protocols to communicate over the network.

Let’s talk about internal working, how app screens are created.




Android Activity

Activity class is very important component of Android. Activity is like single screen with user interface just like frame of java. We know any executable program written in Java or C++ have a main() method and programs are launched with main() method. Instead of main method Android has a different concept of activity.

Most of the apps contains multiple screens which means they have multiple activities. Activities are registered in app’s manifest file. Each activity has its own life cycle you must manage properly.

Here is an example of activity. For more details and comprehensive explanation on Android activities please read our Android Activity Example

package com.example.admin.app;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

Android Intents

Intent allow us to communicate between components. Intent is just like a message used to request an action from another component. It is used for run time binding between the code in different applications.

Android intents

Android intents

Intent has two basic components

Data:  Data to be carried.

Action:  Action to be performed.

There are two main types of intents, explicit intents and implicit intents.

<intent-filter>
                 <action android:name="android.intent.action.INSERT" />
                 <category android:name="android.intent.category.DEFAULT" />
                 <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
             </intent-filter>

Go to our Android Intent Example to find out more about Android Intents

Android Services

A service is a component without user interface that can perform long running operations. There are two types of services in Android.

Service: As it is the base class for Android background service so it runs in the main thread.

Intent Service: It runs in separate thread and is self-destroyed.

Check out our Android Service Example to find out more about Android Services

Android Layouts

Layout is the arrangement of visual components in a frame. Android supports many different layouts like linear layout, relative layout and web view are the most used layouts. You can also mix layouts to apply desired design to your Android application.

Android Studio layouts

Android layouts

Linear layout: organizes components in into a single horizontal or vertical row. Complete example can be found here

Relative layout: It specifies location of components relative to each other. Complete example can be found here

Web view: Used for web pages. Complete example can be found here

0 0 votes
Article Rating
guest
0 Comments
Inline Feedbacks
View all comments