Android UI Main Thread
Android handles input events/tasks with a single User Interface (UI) thread and the thread is called Main thread. Main thread cannot handle concurrent operations as it handles only one event/operation at a time.
Concurrent Processing in Android
If input events or tasks are not handled concurrently, whole code of an Android application runs in the main thread and each line of code is executed one after each other.
Assume if you perform a long lasting operation, for example accessing resource (like MP3, JSON, Image) from the Internet, the application goes hung state until the corresponding operation is finished.
To bring good user experience in Android applications, all potentially slow running operations or tasks in an Android application should be made to run asynchronously.
We had a quick glance on “What an android activity is?” in our previous post, here we are going to discuss about Life cycle involved in an android activity.
Activity in the system is managed as an activity stack. When a new activity is started, it is placed on the top of the stack and becomes the running activity — the previous activity always remains below it in the stack, and will not come to the foreground again until the new activity exits. It might be little bit confusing, let me explain it with an example:
Assume you open Facebook app in your android mobile, you are looking through the shares/posts posted by your friends and you are coming across one interesting web link posted by your friend. You click on the link to view what is there inside, it takes you to web browser and open up the website.
In this post, we are going to discuss about ‘Activity’, for newbies the term ‘Activity’ might be looking like a jargon. Let us discuss it with a very simple example.
What is an Activity?
Activity is a Java code that supports a screen or UI. In other words, building block of the user interface is the activity.
Activity class is a pre-defined class in Android and every application which has UI must inherit it to create window.
Let us create a simple application which displays current time when you just tap the window. We will dissect the code to understand how the activity works.
I hope you have enjoyed ‘My First Program‘ post. Before we proceed with the post, I request you to share this blog to your friends and colleagues who are interested to play around with Android. Our official Facebook has been launched. Like our FB page and keep getting the updates.
Okay, its time to understand the internals of Android OS and folder structure of Android application.
When we write a desktop application, we are the masters of using the controls which range from simple textbox to dialog box. Desktop app usually has main window – Window and child window controls – Textbox, Label etc., We use database to store and retrieve information by using JDBC, ODBC technologies to establish communication between application and DB.
It’s pretty exciting to write about developing first program in Android. In our first program, we are going to have an image and label on the Window.
Its a simple traditional ‘Hello World’ program.
Let us begin with it by opening new android project in eclipse.
Before we proceed with the setup, we should understand what makes Android so special?.
Here is the answer:
Android is a free and open operating system from Google that runs on all kinds of devices from phones, to tablets and even televisions. That’s a ton of different devices you can target with just one platform!. Google provides all of the stuff you need to get started building Android apps for free. Want to learn more about Android, just follow this link
Let’s talk about Android development environment. Android development environment is made up of several parts that work together for you to build Android apps. Let’s take a closer look at each one.