Preparing for Java and Spring Boot Interview?

Join my Newsletter, its FREE

Saturday, July 8, 2023

Introduction of How Android Works for Java Programmers

Android development is a popular buzz in the Java programming world. It's Android, which keeps Java at the forefront of the last couple of years. Now, How important is it to understand or learn Android for Java programmers? Well, it depends on, if you like application development and wants to reach a mass, Android offers that opportunity to you. Millions of Android phones are available and they keep increasing, with pace, much higher than iPhone or iOS. What all this means is, it does make a lot of sense to learn Android programming for Java programmers, and this article is about that, but this is also one of the good reasons 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 have 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 the same tools as IDE like Eclipse or Android Studio if you are an Intellij IDEA fan to develop Android applications, Google provides an Eclipse plug-in for Android development. 

On the opposite, if you want to go for iOS development, a steep learning curve with Objective-C, Swift, 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 them 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 run on Devices?

If you are familiar with Linux and the concept of process, then it's easy to understand how android applications run. 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 others, but they can certainly request access to hardware and other system resources. 

If you are familiar with mobile application development, maybe in J2ME, then you may know about permissions. So when an android application is installed or started, it requests the necessary permission required to connect to 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 the Android application. Unlike the Java Manifest file, the 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 represents 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 screens represents different Activities inside your app.  

best course to learn Android for beginners

Similar to Java, a good thing about Android is that it manages certain tasks on behalf of the developer, one of them is creating an activity object. Activities are managed by System, when you want to start an activity, you call the startActivity() method which takes an Intent object. In response to this call, System can either create a 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? 

Other Android and App Development articles and resources you may like
  • 10 things  App Developer Should Learn this year (skills)
  • The Complete Java Developer RoadMap (guide)
  • 5 Best Android training courses for Java developers (online courses)
  • 5 Free iOS App Development courses for beginners (free courses)
  • Top 5 Java and Android Game Development books (read)
  • Kotlin vs Java? Which One Android developer should learn? (read)
  • My favorite course to learn iOS and Swift (courses)
  • 10 Free Courses to learn React Native for Beginners (free courses)
  • My favorite courses to learn Flutter (online courses)
  • 5 Best Courses to learn Dart Programming Language (courses)


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.

YourFriend 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 :)

Unknown said...

nice guide

Anonymous said...

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

Blogholic said...

How does the code compile ehenit domdo have any main method ? Is it because of Dalvik VM ?

Post a Comment