All about android all 5 stack Linux Kernal, Libraries, Application Framework, Applications, Android Runtime
**Android is an open software plateform for mobile development. it is intended to be a complete stack that includes everything from the operating system through middleware and up through. In this blog I am gonna tell you about android platform And I'm going to talk about some of the key principle that are underlying its design.**
*the whole android architecture is divided into 5 parts given below*
- Linux Kernel
- Application framework
- Android Runtime
1- **Linux Kernel**
We use the Linux Kernel as our hardware abstraction. the reason of using linux kernel is it provides lot of cases existing drivers. it also provides memory management, process management, security model, networking, a lot of core operating system insfrastructure that are robust and have proven over time.
the next level up is native libraries Everything that you see here in green in written in C and at this level where lot of core power of android platform comes from. I am just going to go to through and describe what some of these components are:-
the surface manager is responsible for different drawing surfaces onto the screen. So it's the surface manager that's resposible for taking different windows that are owned by different applications that are running in different processes at different times and making sure that the pixels end up on the screen when they are supposed to.
these two makes the core libraries. OpenGL/ES is a 3D library. We have a software implementation
that is hardware acceleratable if the device has 3D chip on it. The SGL graphics are for 2D graphics and that is what most of our application drawing based on. One more intresting thing about the android graphics platform is you can combine 3D and 2D graphics in the same application.
The Media Framework was provided by Packet Video, One of the members of the open handset, alliance and that contains all of the codex that make up the core of the media experience. So in there you'll find IMPEG, H.264, MP3, AAC, all audio and video codex you need to build a rich media experience.
We use Free Type to render our fonts.
We have an implementation of SQLite, We use that as the core of most of our data storage, We have WebKit Which is the open source browser engine, that's what we're using as a core of our browser. It's the same browser that's powering Safari from Apple and we'd made some, We've worked with that engine to make it render well on small screens and on mobile devices Next is the Android Runtime. And the main component small screen mobile devices
*1- Dalvik Virtual Machine*
The main Component in android run time is Dalvik Virtual Machine Specially for the Android to meet the needs of running in an embedded environment where you have limited battery, limited memory, limited CPU. The Dalvik Virtual Machine runs something called dex files, D-E-X, And these are bytecodes that are results of converting at build time the .Class and .JAR Files, So these files when they are converted to , dex, become a much more efficient bytecode that can run very well on small Processors. They use memory very efficiently. The data structure are designed to be shared across processes whenever possible. And it uses a highly optimized bytecode interpreter. The end result of that is that it's possible to have multiple instances of the Dalvik Virtual Machine running on the device at the same time, One in each of several processes and we'll see why that's important a little bit letter on.
The next level up from that is the Core libraries. This is in blue meaning that it's written in the java programming language. And the Core library contains all of the collection classes, utilities, IO, all the utilities and tools that you've come to expected to use.
Moving up again, we now have the Application Framework. This is all written in java programming laguage and the application framework is the toolkit that all applications use, These applications include the ones that come with a phone like the home application , or the phone it includes applications written by Google and it includes applications that will be written by you. So, all applications use the same framework and the same APIs. Again, I am going to go through and talk about what some of the main component are in this layer:
An Activity Manager is what manages the life Cycle of applications. it also maintains a common backstack so that applications that are running in different processes can have a smoothly integrated navigation experience.
Next down from that is the package manager, The manager is what keeps track of which applications are installed on your device. So, if you download new applications over there or otherwise install applications, it's the package manager that's responsible for keeping track of what you have and what the capabilities of each of your applications are. The windows manager manages windows. its mostly a java programming languages abstraction on the top of lower level services that are provided by the surface manager.
The Telephony manager contains the APIs that we use to build the phone application that's central to the phone experience.
Content providers are a unique piece of the android platform That's a framework that allows applications to share their data with other applications.We use that in our contacts application so that all of the information in contacts, phone numbers, address, names is available to any application that wants to make use of them. And other applications can use that facility as well to share data.
The resource manager is what we use to store local strings, bitmaps, layout,file description, all of the external parts of an application that are't code. I'm just going to touch lightly on the remaining
the view system contains things like buttons and lists, all the building blocks of the UI it also handles things like events dispatching layout, drawing,Location manager, notification manager, and XMPP service are some APIs that I think will allow developpers to create really innovative and exciting applications.
This is where all the applications get written. It includes the home application, the contacts application, the browser, your applications. And everything at this layer is, again using the same application framework provided by the layers below. Now if you're going to write an application, the first step is to decompose it into the components that are supported by the Android platform, Here are the four major ones. We have activity, intent receiver, service, and content provider.
An activity is essentially just a piece of UI typically corresponding to one screen. So if you think something like the mail application, that would be decomposed into maybe three major activities, something that lists your mail, something that shows you what an individual screen to put together an outgoing email.
An intent receiver is something different. An intent receiver is a a way for which your application to register some code that won't be running until it's triggered by some external event. And the set of external events that triggers your code is open and extensible. So you can write some code and through XML, Register it to be woken up and run when something happens, when the network, the network activities established or at a certain time or when the phone rings or whatever trigger makes senses for your application.
A service is a task that doesn't have any UI, that's long lived, that's running in the background.
A good example is a music player. You may start playing some music from an activity,
from a piece of UI, but once the music is playing, you'd want it to keep playing even if you're navigating to other parts of the user experience. So the code that's actually running through the playlist playing songs would be a service, that's running in the background. you can connect to it later if you want to from an activity or some other component by binding to the service and sending and messaging like "skip to the next" or "rewind".
the last component is a content provider and, again, that's a component that allows you to share some of your data with other processes and other applications. Now, any application can store data in whatever may--way it makes sense for that application. They can store it in the files. They can store it in our super light database, whatever makes sense. But if they want to make that data available as part of the platform so that other applications can make use of it, then the content provider is the solution for that and we have used that for the context database that comes with the android platform so that any application can make use of the information in context. Android was designed at a fundamental level to encourage reusing and replacing components. I have an example here that shows how that works. On the left, there are four applications that might want to pick a photo for some reason. So the home application might want to pick it for wallpaper. Contacts might want to pick a person's face to associate with their contact card. Gmail or MMS, You might want to have a photo that you sent to someone in an outgoing message. Now, an Android for these applications to make use of the service of taking a photo, they first need to make a request. So the client component makes a request. So the client component makes a request for a specific action. In this case, I'm illustrating that with a talk ballon and the Gmail application is requesting that it picks a photo. So the talk balloon is actually representation of a formal class in our system called an intent. What the system does when a request is made is it looks at all of the installed components and it finds the best available component that knows how to do whatever was asked for. In this case, Let's say that the system finds the built in photo gallery. Now, what happens is the Gmail applications is now connected to the photo gallery. When the user in Gmails wanted to pick a photo, he will be taken to the photo gallery and the photo gallery will fulfilled whatever was asked for in the intent
what makes it intresting is that the picking of the matching component is late bound, it's done very late and so you can swap software components at any time. So let's say you didn't like the built-in photo gallery and you wanted to replace it with one that went online to find a richer or bigger set of photos. you can replace our built-in photo gallery online to find a richer or bigger set of photos. You can replace our built-in photo gallery with one that say goes out to picasso or whatever your favorite online photo site is. Once you have done that then any of the applications on the left will now use the new and better component on the right to full-fill the task of picking a photo. And at any time, a new application can come along and make use of existing functionality. So if you are writing a blogger application, you dont have to worry about writting a photo picker yourself. you can just rely on that whichever one the user has configured to be their prefered photo picking application. This becomes really important because in Android, it's not just about picking photos virtually any task has an intent in the middle. if the user is going from point A to point B, there's an intent in the middle and each of those intents is an opportunity to reuse a component or to replace a component. so we have intents for going home which means you can replace a home application. or we have an intent for sending an email which means you can replace