Android :: What is an activity And How To Make One?

I will be starting our tutorials in android programming and in this series we will be giving out articles which will help you learn android basics and advanced features and start making your own mobile applications. I have learnt in the past that best way to learn something new is to read about it and then write about it in your own words. That helps you grasp the nature of programming and also helps you in making better applications. I started learning android and wanted to share my knowledge with the world that is why started these series of tutorials.

I am assuming that you know Java Programming and have read about android SDK, downloaded eclipse and setup ADT in the eclipse environment and installed the android API. The basic building blocks should be ready on your machine.

The first important thing to learn about while making android applications is the “Activities”.

What are activities?

To answer this is very simple activity is another name given by android for a “Form” in windows programming. Activity basically is a frame set of user controls and actions put together. To make it more simple, Activity is a user interface you see when you open an android application. All user interfaces that you navigate in an android application are activities and in these activities you define what the user will see on their screen and what to do with the controls present on the screen.

How to create an activity?

An activity is a classed derived from android’s Activity class. To create an activity you have to do the following:

1) In eclipse add a new class and extend it from android’s activity class. The empty class looks like the following code:

import android.app.Activity;

public class AboutUs extends Activity {

}

In the above code snippet the import android.app.Activity imports the library from android api which allows you to create your activity.

The class is Extended from Activity class and is not ready for code.

We will keep updating our Android Programming Tips section every 4 days, please subscribe to our feed and also share our articles on Facebook and Google Plus so other’s can benefit from our insight. Please feel free to send us your comments below, on how we can improve.

No comments yet.

Leave a Reply