Android development is current buzz in Java programming world. It's the
Android, which keeps Java in the fore front from last couple of years. Now, How
important is to understand or learn Android for Java programmers? Well it
depends, if you like application development and want to reach 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 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. On opposite, if you want to go for iOS development, A steep learning curve with
Objective C and iOS SDK waits you. I think it make 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. Any
way, let's come to the topic of How Android works internally. . If you are
looking for some good books to start with Android, you can also check out Professional Android 4 Application Development and Ian F. Darwin’s Android Cookbook.
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. 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 byte
code. 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. Key thing to know is that,
Dalvik VM is based on 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 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
android application, they run on there own process, inside there own virtual
machine. Android operating system manages 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 request necessary permission
required to connect internet, phone book and other system resource. User
explicitly provides grant these permissions, or it may deny. All these
permissions are defined in 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
these screen represent different Activities inside
your app. Similar to Java, good thing about Android is that it manages certain
task on behalf of 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 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 best book to start with Android development, Professional Android 4 Application Development and Android Cookbook by Ian F.
Darwin.
No comments:
Post a Comment