Introduction of How Android Works for Java Programmers

Android development is a current buzz in Java programming world. It's the Android, which keeps Java in the forefront of the last couple of years. Now, How important is to understand or learn Android for Java programmers? Well, it depends on, if you like application development and want to reach a mass, Android offers that opportunity to you. Millions of Android phones are available and they are keep increasing, with pace, much higher than iPhone or iOS. What all these means is, it does make a lot of sense to learn Android programming for Java programmer, and this article is about that, but this is also a one of the good reason to learn Java programming. This tutorial will give you a basic idea of How Android works? not detailed but a good overview.

One distinct advantage Java programmers has over others is that Android API is much like Java API, though Android doesn't support all classes available in J2SE SDK, it supports critical ones. Another advantage is that you can use same tools e.g. IDE like Eclipse to develop Android applications, Google provides Eclipse plug-in for Android development. In order to start with Android, you can also check ouHead First Android Development and Android in Action, 3rd edition, two of the best book to learn Android for Java developers. 


How Android apps runs on device


On the opposite, if you want to go for  iOS development, A steep learning curve with Objective-C and iOS SDK waits for you. I think it makes more sense for a C++ programmer to do Objective-C and iOS, than a Java Programmer. So classic battle of Java vs C++ still continues with Smartphone application development. Anyway, let's come to the topic of How Android works internally. 


How Android works

As I said Android uses Java for application development. So you can code your Android apps using Java API provided by Google, and it compiles into class files. The similarity ends here, Android doesn't use Java Virtual machine (JVM) for executing class files, instead, it uses Dalvik virtual machine, which is not a true JVM and doesn't operate on Java bytecode. In order to run on Dalvik Virtual machines, class files are further compiled into Dalvik Executable or DEX format. After conversion to DEX format, class files along with other resources are bundled into Android Package (APK) for distribution and installation into various devices. 




The key thing to know is that Dalvik VM is based on a subset of the Apache Harmony Project for its core class library, which means it doesn't support all J2SE API. If you are using Eclipse IDE for coding Android Apps, then you don't need to worry much because it will help you with code completion. Now let's see How Android Application runs on a device?



How Android apps runs on Device

If you are familiar with Linux and concept of process, then it's easy to understand how android applications runs. By default, Each Android application is assigned a unique user id by the Android operating system. After starting an android application, they run in their own process, inside their own virtual machine. 

How Android works , app runs on device from Java programmers

Android operating system manages the starting and shutting down the application process, whenever required. This means each android application runs in isolation with other, but they can certainly request access to hardware and other system resources. 

If you are familiar with mobile application development, may be in J2ME, then you may know about permissions. So when an android application is installed or started, it requests necessary permission required to connect the internet, phone book and other system resources. The user explicitly provides grant these permissions, or it may deny. 

All these permissions are defined in the manifest file of Android application. Unlike Java Manifest file, Android manifest is an XML file, which lists all the components of apps, and settings for those components. 


Four major components of Android application development is Activities, Services, Content Providers and Broadcast Receivers. Activity is most common of them, as it represent a single screen in Android Application. For example, in an Android Game, you can have multiple screens for login, high score, instructions and game screen. Each of this screen represents different Activities inside your app. 

Similar to Java, a good thing about Android is that it manages certain task on behalf of the developer, one of them is creating activity object. Activities are managed by System, when you want to start an activity, you call startActivity() method which takes an Intent object. In response to this call, System can either create new activity object or reuse an existing one. 

Just like Garbage collection in Java, manages a critical task or reclaiming memory, Android manages the starting, stopping, creating and destroying of apps by themselves. You may think it's restrictive, but it's not. Android provides life-cycle events, which you can override to interact with this process.


That's all on How Android works.  Android is definitely worth learning for Java programmer, as it uses Java, you can reuse your existing knowledge of Java programming techniques, design patterns, and best practices to code a good android app. Of course, you need to adapt some Android specific things like, but those will come along. So, what are you waiting for, go and explore more about Android and write an Android HelloWorld application?  Finally, you can also take a look some of the good books to start with Android development e.g. Head First Android Development, the best book to learn Android.

10 comments :

KC said...

Good introduction for Android.
I think now on wards we can discuss about Android also on this blog

AlexanDerrhode said...

If you are acquainted with Linux system and idea of process, then it's clear and understandable how android os programs operates. By standard, Each Android application is allocated a unique user id by the Android os.

alliancetekinc said...

Thanks for share with us....
Android application has surfaced in the industry in the recent past. As a matter of fact, there are some strong reasons attached to this. Android is an open source platform and allows the developer to gain an edge over his competitors. The developer’s community is constantly working on different applications and feeds it with some of the latest technical and sophisticated advancements. This ensures that the Android platform is less vulnerable to breakdowns

Chatur said...

Please post some more articles on Android and game development in Android.

Unknown said...

Excellent intro to Android. Thank you for sharing.

YourGeek Fellow said...

Nice Overview

Java is also architectural neutral unlike C++ and other languages

Mainak Goswami said...

Excellent article Javin. Looking forward for more articles on Android. If you can highlight more on the game development side of it then it will be really helpful.

BISHNU said...

Nice article , it could have been better if you are able to share some good Android article links :)

Vicky Rana said...

nice guide

Azaldin Freidoon said...

The Dalvik virtual machine has been discontinued, Google now uses Android Runtime (ART) although it still uses the same bytecode and .dex files

Post a Comment