[Tutorial Part:1] Introduction To Android Mobile Operating System
Hi friends, from now onwards we are going to start our new Android tutorial section, hope you will enjoy it !!! Please put your suggestions and question w.r.t our new 'Tutorials Section', we are happy to hear from you !!!
“Android is a comprehensive open source platform designed for mobile devices”.
I want to make slight change in this statement, "Android is a comprehensive open source platform designed for electronic devices..."
i.e. After some days or may be by the end of the year we are going to use electronic devices which is having android environment.
Android is championed by Google and owned by “Open Handset Alliance”.
Why do we develop app for android?
Many questions may be arising, ‘Do I want to develop apps for open source environment? Can I make money from all this? ‘If these are the questions and you want to give an answer only “YES”, then you are on right path. So lets start…..
1. ANDROID ENVIRONMENT-
As I mentioned earlier Android is an open source, means that you can download the source code of android, can customize it and use it for your purpose.
2. ANDROID FEATURES-
- Application framework enabling reuse and replacement of components.
- Dalvik virtual machine optimized for mobile device.
- Integrated browser based on the open source WebKit engine.
- Optimized graphics powered by a custom 2D graphics library: 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional).
- SQLite for structured data storage.
- Media support for common audio, video and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF).
- GSM Telephony (Hardware dependent).
- Bluetooth, Edge, 3G and WiFi Hardware (Hardware dependent).
- Camera, GPS, compass and accelerometer (Hardware dependent).
- Rich development environment including a device emulator, tools for debugging, memory and performance profiling and plugin for Eclipse IDE.
3. ANDROID ARCHITECTURE-
As we can see, the diagram contains following parts-
- Linux Kernel.
- Application Framework.
Android was created on top of the open-source Linux 2.6 kernel. Android stack designed to be flexible. A Linux kernel provides a foundational hardware abstraction layer as well as core services such as process, memory, and file-system management. All can says that Linux is such operating system that Android relies on its basic powerful features to mold itself for better services.
Libraries are C/C++ libraries, often taken from the open source community in order to provide necessary services to the Android application layer.
4. It includes:
Open GL (graphics library): This cross-language, cross-platform application program interface (API) is used to produce 2D and 3D computer graphics.
WebKit: This open-source Web browser engine provides the functionality to display Web content and simplify page loading, finds in Mac’s Safari and iPhone’s Safari browser.
SQLite: This open-source relational database engine is designed to be embedded in devices.
Media Frameworks: These libraries allow you to play and record audio and video.
Secure Sockets Layer (SSL): These libraries are responsible for Internet security.
Apart from these libraries, other libraries include in this environment, ‘Android Run-time’, which includes ‘Core libs, Dalvik VM’.
Core libs: Core Java packages for a nearly full-featured Java programming environment.
Dalvik VM: If we compare it with Java Virtual Machine we can quickly know how dalvik virtual machine works.
In Java, you write your Java source file, compile it into a Java byte code using the Java compiler, and then run this byte code on the Java VM. In Android, things are different. You still write the Java source file, and you still compile it to Java byte code using the same Java compiler. But at that point, you recompile it once again using the Dalvik compiler to Dalvik byte code. It is this Dalvik byte code (dex file) that is then executed on the Dalvik VM.
|Android version||API level||Other Name|
|Android 2.2||8||Froyo (frozen yogurt)|
|Android 3.1||12||Ice Cream|
- BROADCAST RECEIVERS
- CONTENT PROVIDERS
Activity is a simply a single screen in your application that the user sees on the device at one time, for example, a list of email is one activity, message details for particular message is another activity. An application typically has multiple activities, and the user flips back and forth among them.
Even if the activities work together, they are independent of each other. Each Activity is implemented as the derived class of Activity class. An application may have one or any number of activities. One of the activities is marked as the first one that should be
presented when the application starts. First Activity invoked can in turn invoke other activities.
A service doesn’t have a visual user interface, but rather runs in background for an indefinite period of time. The best example of service is our antivirus which is installed in PC.
A broadcast receiver is a component that receives and react to broadcast announcement. For example, you play music on your phone, at that time a pop-up message may notify about “Batteryis Low”, so your music player is broadcast receiver, so we can say that any application which is currently running on your phone can get that message (independent of their usage).
Content provider is mediator between the application and the database, the database which is related with application, which contain all stuff require by application. By default, Android runs each application in its own sandbox so that all data that belongs to an application is totally isolated from other applications on the system. Although small amounts of data can be passed between applications via intents, content providers are much better suited for sharing persistent data between possibly large datasets. A content provider makes a specific set of the application's data available to other applications. Here I am saying that ‘specific’ data, not all.
The canonical ContentProvider example in Android is the contacts list—the list of name, address, and phone information stored in the phone. You can access this data from any application using a specific content provider and a series of methods provided by the Activity and ContentResolver classes to retrieve and store data.
6.ACTIVITY LIFE CYCLE-
We have to create and implement an activity for each screen in our application.
So, we prepare priorities of processes-
- Foreground activity is most important.
- Activity is visible but not foreground.
- Background activity.
- Empty Process.
An activity has essentially three states:
When we are saying that activity is starting, it directly dealing with battery resource. In android activities are maintain by stack application, means the activity which is currently running and which has seen by user on screen of device, is kept on top of the stack. Android tries to keep processes running as long as it can, but it can’t keep every process running forever because, after all, system resources are finite.
User may want to make a call while he playing a game, he may receive a message which in turn can affect overall system resource. This is the exact reason why we don’t automatically destroy activities that are no longer shown. The user might want to come back to them, so we keep them around for a while.
Every process has to implement onCreate() method, this starts the life-cycle.
After getting started by onCreate() method, the process may execute onPause() method, so data can persisted.
It is stopped if it is completely obscured by another activity. It still retains all state and member information. However, it is no longer visible to the user so its window is hidden and it will often be killed by the system when memory is needed elsewhere.
So, we are focusing on methods and purpose of that method.
|onCreate()||This method is called when an activity starts.|
|onStart()||Now in this, activity becomes visible.|
|onResume()||Called when an activity becomes foreground activity.|
|onPause()||Called when an activity Saves uncommitted data.leaves the foreground.|
|onStop()||Called to stop the Activity and transition it to a nonvisible phase|
|onRestart()||Called if the Activity is being restarted, if it is still in the stack, rather than starting new.|
|onDestroy()||Called when an Activity is being completely removed from system memory|
Whatever we have seen for activity life cycle, it doesn't mean that it’s doing much. It only happens and responsible for user input.
So friends now its worth for introduction,we will going into details in Android development with our up-coming articles, so keep reading & put your queries and doubts in comment section.