Wednesday, June 15, 2022

Java mobile applications

Computer programs are determined by the hardware they are built with. If you are building a rich client application with the JVM then you are probably targeting two types of hardware (1) desktop hardware and (2) mobile and embedded hardware. Different types of hardware necessitate different types of software, and so lets explore these distinctions in more detail.

Size matters

When computers were first created they were the size of an entire room. There was a large period of computing history when there were no personal computers because they were too cumbersome, large, and didn't have any graphical user interface capabilities. A long standing trend in the history of computing has been that they have been getting smaller so they take up less space.

A phase transition in this continuous process occurred in the past decade and a half or so, when computers became so small they could fit in your hand. They even became smaller then your keyboards. This radical change in hardware necessitated a different user interface paradigm based upon technologies like touch and speech.

This produced the most significant change in human-computer interaction technology in the last decade and a half. Now graphical user interface applications (GUIs) need to made to adapt to either desktop devices or mobile devices. A lot is shared in common between the two kinds of devices, but other things like differences in input devices pose a challenge for graphical user interface designers.

Every single GUI application has to ask itself it is targeting a mobile device or a desktop one. These hardware differences change the APIs that we have to look in to. Fortunately, as JVM language developers we have a pick of APIs including Swing for desktop applications and Android for mobile applications. With these, we can build graphical user interface applications for any device. Beyond these two, there are a couple of specialized client application frameworks with more advanced graphical capabilities.

Mobile devices

Mobile devices have specialized hardware which distinguishes them from desktop devices. Firstly, in mobile devices energy usage and heat dissipitation are significant factors. As mobile devices are not typically hooked up to a power supply, every piece of energy used by them is significant. At the same time, since they are held in our hands if they heat up too much that will effect the user. This is one reason why mobile processors tend to use ARM.

Secondly, mobile devices have different input and output devices configurations. Mobile devices lack the keyboards and mouses of standard hardware devices, both of them being replaced by touch screens. Further, the screens of phones and other mobile devices are too small to fit many standard applications.

Java SE provides means of handling printers, monitors, keyboards, mouses, processors, storage devices, etc in APIs distributed through a number of different packages, but it doesn't provide us with the means of handling mobile devices like phones. These distinction hardware configurations are handled by the Android APIs, which contain a number of Java SE packages but not Swing which is specifically for desktop applications.

Virtual mobile devices


You certainly wouldn't want to program on a mobile device when it doesn't have a keyboard. This produces a distinction between the devices you program on and the devices your programs run on. Fortunately, Android Studio provides the means to solve this by allowing you to create virtual mobile devices. That way you can run your Android programs right from your desktop.

To begin with, download Android Studio. Then open the device manager and select create device. As all Android applications are dependent upon the hardware they run on, you next select the hardware you want to emulate. Then select a system image for the Android API and click next change the virtual device as you needed and finish. With that you can get around the hardware differences between desktop and mobile applications and get to developing.

Android API

As mobile devices are a different sort of hardware then desktop devices they require their own API, but this by no means implies that there is no overlap between Java SE and Android. Most of the classes in the base, logging, preferences and SQL modules are available for use in Android applications.

As Android is based upon a different interaction paradigm then Swing, the desktop module is noticeably absent. Swing is suitable for the sort of hardware devices in desktop computers, while Android is more suitable for the sort of hardware configurations in mobile devices. Both serve their own purposes by targeting different types of hardware. Swing still has its use cases and a set of hardware that it targets.

A Java virtual machine for every device

The JVM is the best developer platform in the world. In order for it to maintain its status as the best developer platform into the future, it must have APIs for all kinds of hardware devices. With the different Java APIs like Android and Java SE that is now possible. Each different type of hardware has its own API.

Separately, Java ME provides support for embedded and mobile devices programmed with Java. It should be noted that Java ME is not the same thing as Android. Java ME is the historical API developed by Sun microsystems, while the Android API is used on most modern mobile devices. Both of them use a subset of Java SE.

External links:
Android Studio

Android API

No comments:

Post a Comment