How will Java 8 improve Android development

Let's see how it works

Android Development for Windows Developers - An Introduction

Android cannot be ignored in the mobile sector. Many developers are at home in the Windows world and wonder how easy or difficult it is to get started developing apps for Android devices. An introduction for Windows developers.

No question about it, there are already some good books that promise a quick and uncomplicated introduction to the program development of apps for Android. Whether a tutorial turned out well or not is, among other things. also strongly dependent on the respective perspective of the observation. Ideally, you will find a document that picks up those interested in learning exactly where they are.

A few years ago, the development of apps for mobile devices did not play a major role. Classic user software was primarily developed for the desktop. The various versions of Microsoft's Windows operating systems are clearly dominant. A large number of programmers have been at home in this "ecosystem" for many years: They know the structure of the system, the way in which the application is developed, the frameworks and libraries used (for example .NET) and the established programming languages ​​(for example C #, C ++ and Java). If you want to develop apps for mobile devices now, you can of course also choose Windows Phone versions 7 and 8. The user interfaces can then be created with XAML (Silverlight), the .NET Framework is available in a "slimmed-down" version. In the mobile sector, however, the operating systems are being prepared differently. According to current statistics, Windows Phone ranks after Android and iOS. If you make applications available for use on smartphones and / or tablets, from today's perspective you are practically forced to support the Android system as well. The developer is therefore required to deal in detail with the program development of the Android system, which is based on a Linux kernel. The key question will be: How much knowledge from my previous system environment can I use and successfully contribute?

This two-part series of articles gives a compact introduction to the development of apps for Android and takes the perspective of the established Windows developer. Thus, two points in particular are considered:

    1. What are the similarities between the two systems, i. H. how can one transfer the known knowledge into the new system environment and use it there?
    2. One especially has to point out the differences. Occasionally, as a “well-versed” Windows developer, one expects something completely different, or one would approach the solution of a problem completely differently. In this case, prior knowledge is even detrimental as it requires an active relearning process.

Android for Windows Developers - A three-part introduction

In this series of articles we present a compact introduction to the development of apps for mobile devices with an Android system.


Android is an operating system (based on the Linux kernel 2.6) and a platform at the same time. This includes a number of standard applications (e.g. contact database, clock, browser, ...). The applications are usually obtained via Google Play. The virtual machine Dalvik (developed by Dan Bornstein, named after a small fishing village on Iceland) is also part of Android. The applications (apps) are not executed directly by the processor of the mobile device, but in instances of this virtual machine. This approach leads to increased security and overall better stability of the platform. Dalvik has been optimized to minimize memory consumption. The virtual machine and the so-called core libraries together form the Android runtime. The core libraries include: the packages known from Java such as java. Lang,, java.math etc. The application framework is arranged in one layer above the libraries and the Android runtime. This enables the creation of user-friendly apps with little effort. Components of the application framework are:

  • Views: Includes standard operating elements such as text fields, buttons, etc.
  • Content Provider: Controls the access to the data of other programs.
  • Resource Manager: Provides character strings, graphics and layout data.
  • Notification Manager: Guarantee of access to the status line.
  • Activity Manager: This is used to manage the life cycle of an app.

The life cycle of an app in the Android system differs from that of a desktop application. This can be shown as in Figure 1. Figure 2, on the other hand, shows the structure of the entire Android platform.

Fig. 1: Life cycle of an Android app

Fig. 2: Structure of the Android platform

Set up the system environment

The first and most important step is to set up the system environment. To do this, the prerequisites must be created to program, test and install apps on a target mobile device. A few steps are necessary for this, which we describe in the following as an example for the implementation of a first test application for an Android tablet. According to our approach, we assume that the development is carried out on a computer with Microsoft Windows 7 or 8 operating system. The individual steps include:

  1. Update of the operating system and collection of information: Now is the best way to bring the development computer up to date with the operating system. To do this, the Windows update function should be called and all important updates installed. It is also useful to take a look at the optionally available updates. Nevertheless, you should find out the correct version of the operating system, e.g. Windows 7, 64 bit. And for a good reason: Occasionally, manufacturers of mobile devices offer the necessary drivers for a specific system. Other software must also match the operating system version.
  2. Complete installation of Java: The development of apps for Android is based on the Java programming language. For this we not only need the current runtime environment, but also the current version of the Java Development Kit (JDK). This can be downloaded here. The installation is carried out in the tried and tested manner using a setup program. Additional settings are not necessary.
  3. Check and update system paths: The entries in the system path are used to make it easier to call the auxiliary programs that are occasionally required (usually to be started via the console) throughout the system. To do this, go to “System and Security” in the Control Panel and open the “Advanced System Settings” dialog box (Fig. 3). The "Environment Variables" button takes you to the dialog box. There the "system variable" is to be added to the entry of the bin directory of the current JDK installation (Note: The entries are separated by semicolons; for example, add the entry C: \ Program Files (x86) \ Java \ jre7 \ bin as shown in Figure 4). Using the command line, you can quickly find out whether the installation of Java and the update of the environment variables worked. To do this, enter the command javac -version in a console window (Start | Run | cmd). The result is the display of the installed version of Java. As I said, this should work from any directory via the console. The Java home directory must also be made known. This is also created in the "Environment Variables" dialog box (upper area). For this purpose, a variable JAVA_Home is defined, which refers to the Java root directory.

Fig. 3: "Advanced System Settings" dialog box under Windows

Fig. 4: Adding the path information to the “Java / bin” directory in the environment variable

  1. Connection of the hardware: In order to develop apps successfully, it is imperative to test them on real hardware. The Android development kit (Android SDK) also includes an emulator, but this is relatively slow and can never replace a test on real hardware. Now the possible hardware with Android systems is more than heterogeneous - this includes smartphones and tablets of various categories. The notes are therefore more of an exemplary nature. The mobile device is usually connected to the development computer via USB. A special driver (USB-ADB driver) is required to install apps on it. This is usually obtained from the manufacturer's support pages. As a rule, the end device is automatically recognized as a removable disk. However, this is not sufficient for installing apps; the special driver mentioned is responsible for this. This can be installed via the device manager. The author did this for a Medion tablet (P9516). After successful installation, the tablet is called “Android Phone | Android Composite ADB Interface ”(Fig. 5). After the driver has been installed, the system needs to be rebooted. Instructions for installation under Windows 8 can be found in the text box "Installation instructions for the Android Debug Bridge (ADB) driver under Windows 8".

Fig. 5: Successful installation of the device driver for the mobile device

  1. Software for program development: Eclipse is chosen as the development environment. Although there are now alternatives (for example Android Studio, in an early beta version), the use of Eclipse is established. A separate software development kit - the Android SDK - is required to develop the apps. This provides the interfaces to the (API) for program development. To make matters worse, there are several Android platforms (in the sense of versions) with the associated APIs. You should think carefully about which platform you are developing for later. The problem with relying only on the latest API is that too many devices that are still on the market are excluded. If, on the other hand, you choose a version that is too old (for reasons of compatibility), you have to forego many advantages. A good compromise (for the general app) or a careful selection (with a clear target group with known devices) is therefore required. Figure 6 shows the Android version distribution (as of early 2014). Here you can find more interesting statistics about the hardware used, for example the display resolutions of the devices used. This is an important statement for the development of the user interface.

Fig. 6: Android version distribution at the beginning of 2014

Installation instructions for the Android Debug Bridge (ADB) driver under Windows 8

Due to the stricter security rules, Windows 8 requires a slightly different procedure for installing the device driver if it is not digitally signed:

  1. Press Windows key + i at the same time
  2. Hold down the Shift key and restart
  3. Select Troubleshoot
  4. Select advanced options
  5. Select startup settings
  6. Select Restart, press F7 or 7
  7. Hold down the Shift key and restart

The connection between Eclipse and Android SDK is established by a plug-in for the development environment. The SDK version and plug-in must match each other. Instead of installing Eclipse, Android SDK and plug-in separately, a complete package is available. This software collection - known as Android Developer Tools (ADT) - contains other tools for app programming. The current version of the ADT can be downloaded here. Here, too, a distinction is again made between 32 and 64 bits. The ADT are approximately 480 MB when packed. After the download it has to be unpacked (> 1 GB); it can therefore take a while. Then we find two folders (\ eclipse \ contains the files for the development environment and \ sdk \ contains the files for the software development kit, including the data for the selected platforms). The so-called SDK manager is also included in the root directory. The next step is to start it (Fig. 7).

Fig. 7: The Android SDK Manager is used to select the platforms (APIs) to be installed

Now the platforms have to be selected for which a development is to take place. Updates are also managed using this tool. The author initially selected the platform “Android 4.0.3” (corresponds to API version 15), as the present tablet uses this operating system version - at this point you should check the Android version of your target device. After the selection, the download or the update can be started; if necessary, the license terms have to be confirmed. The installation takes place in the folder \ sdk \ platforms \.

Starting the development environment (Eclipse) is easy. To do this, change to the \ eclipse directory and start the executable file eclipse.exe. A separate installation of the IDE is not required. This allows you to move the entire development directory (including Eclipse and SDKs) within the system. After starting Eclipse, you are first asked to define the workspace - i.e. the central working directory. Then you get to the start page of the IDE, which is already geared towards the development of Android apps. At this point the “installation marathon” is over. The technical requirements for our first app are now in place.

At the MobileTech Conference 2015 in Berlin from August 31 to September 3 there will be a lot of interesting sessions for mobile developers.

In these MobileTech-Con-Sessions you can find out more about the development for Android, iOS & Co .:


A first app

We want to implement this right away. The point is to create a first executable application that has a rudimentary UI and can already be started ("Hello World"). As is usual in modern integrated development environments, an assistant helps to create the basic structure and generate the frame code. The specific functionality must then be added. For Eclipse (similar to Visual Studio) an app is a project. A new project is started via File | New | Project started (Fig. 8).

Fig. 8: Start a new Android project

A wizard follows, which asks for the basic settings for the planned project. In the first dialog box, these are:

  • Application Name: The app will later be registered under this name on the device and in the store. The name of the start activity (start form) is entered in the app list.
  • Project Name: Name of the project in the IDE and the name of the subdirectory in the workspace.
  • Package Name: Packages are elements of the Java language (comparable to the namespaces of .NET). Usual designation in the orientation of the website, for example: itfachartikel.testapp. The spelling is important: small!
  • SDK versions: Minimum, Target, Compile - Specification of the SDK versions for the respective purpose; if in doubt, choose the same version for all entries.
  • Theme: Selection of the basic theme (color scheme) of the app.

The information in the second dialog box (Create Custom Launcher Icon, Create Activity, Create Project in Workspace) is left unchanged. In the third dialog box of the wizard, you are asked to select the icons. For this first test app, everything remains with the default settings. After clicking on “Next”, the start activity and its name are selected in the following two dialog boxes. After these steps, all information has been obtained from the wizard and Eclipse is ready to build the basic structure of the first app. Be curious!

The project structure of an app becomes clear in the Package Explorer in Figure 9.

Fig. 9: The Package Explorer to illustrate the project structure

At the beginning it is enough to identify the most important elements:

  • src: The source code files are in this folder.
  • gen: automatically generated Java files; manual processing is not intended.
  • libs: libraries, depending on the target platform.
  • res: folder for resources (image and text elements).
  • res \ layout: The data for the forms of the app, defined in XML.

As an example, we click the activity_main.xml file in the \ res \ layout folder. Eclipse then displays the appearance of the activity in its own designer (Fig. 10). The experienced developer will find familiar elements on the right edge of the screen. For example, the structure of the UI from the elements is displayed (outline) and the values ​​of the individual properties of the control elements of the surface can be configured in the Properties Editor. Similar to the design of the user interfaces for Windows Presentation Foundation, the designer generates XML code (under WPF: XAML code, a "variety" of XML). The form design is therefore a combination of designer operation (mouse interaction), adjustment of properties (properties editor) and ultimately post-processing of the XML code for Android apps as well.

Fig. 10: Eclipse contains a designer for designing the UI of the app

Before we start the app for the first time, let's take a look at the app's initial source code. This can be found under \ src \ de.itfachartikel.testapp \ for the example. A click on the file leads to the display of the source code (Listing 1). The name of the package is in the top line.This is followed by import instructions (in C # usings) for integrating the required libraries. A MainActivity class is defined, which inherits (extends) important features of the Activity base class. When the application is started, the onCreate (…) method is called. In this, the layout of the app is defined via setContentView (…).

Emulator and real hardware

Now it is a matter of reaping the fruits of these efforts. The app is created and started. We want to test the app both in the emulator and on real hardware. First of all, the automatic build has to be switched off (Project | Build Automatically). Then it is necessary to save the entire project (File | Save all). The changes are only processed if they were saved before a new build. You create the project manually via Project | Biuld Project. Any errors in the source code would be highlighted in color. To test the app in the emulator, you have to create a virtual Android device and configure it with the desired features. An Android Virtual Device (AVD) can be created as follows:

  1. Start the Android AVD Manager (directly from Eclipse via Window | Android Virtual Device Manager).
  2. A new device is created via "New" (11).

Fig. 11: Configuration of a new virtual device in the AVD manager

Now the app is started in the emulator. About Window | Show View | Console, the current messages can be followed in a separate window. To finally start the app, activate the root node (TestApp) in the Package Explorer. Then call Run | Run As | 1 Android application. The start of the emulator is anything but fast, so it should not be closed immediately after testing the app. It is enough to minimize it. For the next test run, the revised app is then simply reinstalled on the virtual device and started. After what "feels like" an eternity, the virtual device is actually displayed in the emulator including our app (Fig. 12). Congratulations!

Fig. 12: The started app in the emulator

Working with real hardware is much more fluid. To do this, make sure that it is connected via USB and that the debug driver is correctly installed (see above). The menu item Run | is called Run Configurations on.

Choose the option “Always Prompt To Pick Device”. Confirmation takes place with "Apply". Then the dialog box is closed. Lo and behold - after really a few moments, our first app on the real tablet does not appear virtually at all.

Outlook and conclusion

In this introductory article we ventured into the adventure of app development for Android devices from the perspective of a classic "Windows developer". Most of the explanations were devoted to the rather large installation and set-up effort. The Eclipse development environment also (still) feels unfamiliar. Similar functions as in our beloved Visual Studio are available, but many things work differently. The time during the installation of the necessary software can be used sensibly and at the same time read into the “ecosystem” Android. In the next, second part, we will deal with the options for designing the user interface for the apps. Again, there is Windows Forms and Windows Presentation Foundation (WPF) to try again the Windows world to relearn one or the other. A final note: The source code for this test project for platform 4.0.3 and the IDE Eclipse is available for download.

Read on here: Android Development for Windows Developers - An Introduction [Part 2]

Mobile Technology

This article was published in Mobile Technology. Mobile technology is the companion for everyone who deals professionally with the development of mobile devices and the possibilities that the mobile business and marketing market has to offer.

Of course, you can also read the mobile technology digitally in the browser or on your Android and iOS devices via the developer.kiosk. Mobile Technology is also available in our shop by subscription or as a single issue.

Our editorial team recommends: