- Converting an existing Java program to Android.
- Developing an application for both Java and Android.
- Have some experience with Java and want to learn Android.
Android can be thought of as a direct descendant of Java. Not only do the languages share are large common core, but also many existing Java libraries can be used in Android apps directly and without modification or recompilation. This makes Android a relatively easy step for anyone who has a Java background.
Let's take a look at some of the well-known package names from the Java SDK. Those on the left are also included in Android. Those on the right are in Java only.
|Packages in Java AND Android ¹||Packages in Java but NOT Android|
It's clear that a very large chunk of the JDK is available to the Android developer. In addition, because Java libraries can incorporated into an Android app, it means any existing Java library can be used as long as it only needs packages from the left-hand column.
Turning now to the right-hand column, arguably the most significant "missing" packages are the ones related to user interface building, java.awt and javax.swing. This is because Android has its own system for building UI elements - more on this in another article coming soon.
So what to conclude from this, and how should it affect the design of an Android app we might want to build? Good application design should separate the core program logic from the user interface. If this principle is used, it will also make life easier should you want work with both Java and Android. The program logic parts of the app are typically going to use packages common to both languages, and hence can be easily reused.
A pure Java user interface cannot be reused however, and so an Android-specific version will need to be built. We will look at aspect more in the next article (coming soon).
For those developing an application for both Java and Android, or wanting to migrate an existing Java application to Android, here is a simplified diagram of how an app might be structured.
In the next article, we will explore in more detail the differences between Java and Android, and how we might navigate these to build our Android app.