How fluid is the Phonegap camera function

1. Introduction

Status: June 21, 2018

In this lecture we learn the development mobile apps. We understand an app to be a computer program that runs on a mobile device, typically a smartphone or a tablet, runs or for a mobile operating system how iOS or Android OS was developed.

Mobile devices also include smartwatches, smart glasses, computers in the car, in the house and in everyday devices (keyword Internet of Things). Corresponding technologies such as Wear OS (formerly Android Wear) and Android Things are already available for Android. Here we limit ourselves to smartphones and tablets.

The breakthrough of smartphones brought about some dramatic technical and conceptual changes with regard to the concepts of "program" and "user interface".

1.1.1 Traditional programs vs. apps

On Desktop computers and notebooks "Programs" are relatively complex applications, e.g. word processing, photo editing, e-mail management, Internet browsers, etc. Computers, which mainly have and use their own software on the hard drive, are also called Fat clients or Rich clients.

On Rich clients usually run traditional programs with the following properties:

  • large range of functions
  • complex graphical user interface (GUI)
    • multiple windows
    • Subdivisions in partial windows (panes)
  • access to local file system is common
    • Files as a link between programs: program A saves a file, program B reads a file
  • Interaction with external applications (e.g. browser or mail) rarely

On mobile devices (Smartphones, tablets) one speaks more of a App instead of a program. Apps often have a specific task (calculator, alarm clock, notepad, address book, camera), but can also become very complex (mail, browser, computer games). Apps have the following properties:

  • focused range of functions
  • GUI takes whole screen one, transitions between screens
  • access to local file system rarely, instead idea of ​​sharing
  • Apps routinely call up external apps (mail, chat, camera, browser, photo management, etc.) and "share" (share) corresponding data (e.g. image, text, link)

Another important difference from the user's point of view is of course that Cost of an app. While a desktop program is more in the range of 50-300 EUR, many apps are free or are sold for 1-30 EUR. In the case of apps, "in-app purchases" are often used, i.e. you can activate certain functions (or switch off advertisements) after purchasing the app for an additional fee.

Naturally blur these categories more and more and developments in one category have influenced the other. In the meantime, notebooks are also referred to as apps (including the corresponding app stores). Tablets are increasingly becoming powerful notebooks with the identical operating system (Windows).

This fusion of philosophies is made possible by the category of Web applications driven, i.e. applications that run within a browser. These applications target both the desktop and the smartphone and are always finding innovative solutions to unite these two worlds.

1.1.2 Native apps

We deal with the development native apps for Android. This means that we choose a programming language and libraries that are very close to the Android platform or are identical to the technologies that the developers of the operating system also use. On Android this is called the programming language Java. On Apple devices, for example, that would be the language swing (formerly Objective-C).

The great disadvantage Of course, native app development means that you can only use the app on one platform and the app for other platforms (e.g. Apple smartphones) develop anew got to.

There are several possible solutions to this problem.

The simplest is to call a service Web application offer, i.e. via interactive websites that can be used with any browser. This has various disadvantages: you always have to start a browser first, you cannot sell the app via an app store, animations do not run quite as smoothly, the look'n feel does not correspond to that of the native apps and there is almost always an internet connection necessary.

Hybrid apps take up this idea and use web technologies such as JavaScript and HTML / CSS to program platform-independent applications. The final application basically consists of an embedded browser (as a runtime environment) and the code. A well-known framework is Cordova or PhoneGap. The disadvantage of hybrid apps is that the user interface often does not match the standard look and feel of the respective platform. In addition, there can be performance problems with animations.

Cross-platform apps are also developed with a framework and then compiled for the respective platforms. The UI systems of the respective platforms are used for this. Well-known frameworks are Xamarin and Appcelerator.

Android is based on the popular LinuxOperating system and has multiple layers. Each layer only accesses the one directly below. It is also said that a layer "encapsulates" the functionality below.

So if you program your app in Java, you have nothing to do with Linux or C ++ directly.

1.2.1 Version, code name, API level

Android has a long version history and unfortunately there are many devices with older versions than the current one.

The Versions are named with a number for the major version and a number for the minor version, for example version 8.1. Each Major version is named after a sweet as a code name, e.g. "Oreo" for version 8.1.

In addition, there is the API level a continuous numbering across all sub-versions away. Version 8.1, for example, has API level 27 (one also simply says "API 27"). When developing, the API level is usually used because you can easily test which of two versions is higher with a single number. "API" stands for application programming interface (Interface for programming applications).

Here you can see one abridged history the versions, code names and API levels. A complete overview of the versions can be found on Wikipedia.

versionCode nameAPIRelease
8.1Oreo2712/2017
8Oreo2608/2017
7nougat2408/2016
6Marshmallow2310/2015
5Lollipop2111/2014
4.4KitKat1910/2013

On the distribution dashboard you can see how widespread which version is (as of 05/2018):

When you start a new project in Android Studio you will be asked which minimum version your app should require. At the same time, you will see how many devices you cover worldwide. At KitKat (API 19) you can currently see, for example:

1.2.2 Requirements

To program Android apps you need:

  • Java SDK: The basic package for the Java language
  • Android SDK: Packages specifically for Android programming
  • Android Studio: programming environment for creating and managing code
  • Emulator: program for simulating an end device

1.2.3 From code to app

In Android Studio you write Java Source code. This source code is known to be too Bytecode translated (files with extension .class). However, Android requires special bytecode, the so-called Dalvik bytecode and therefore translates the bytecode into .dex files. These files are packed (ZIP) together with the resources (images etc.) in a .apk File, a Android Package.

See an article by David Griffiths (author of Head First Android Development) for more in-depth information.

Android Studio has been the "official" development environment for Android devices since 2013/14. It is made available by Google free of charge for all major operating systems (Windows, Mac, Linux).

The Version 3 and is based on the Java development environment IntelliJ IDEA the Czech company JetBrains.

1.3.1 Android Studio

The main things you do in Android Studio are:

  • Programming an app, i.e.
    • Create Project
    • Write code (classes)
    • Design the layout of the screens
  • Compile your app and transfer it to an end device (usually via USB cable)
  • Alternatively, start the app in an "emulator" that simulates an end device on your computer (if you do not have an end device or want to test alternative end devices)

Android Studio uses several software tools internally to accomplish its many tasks.

In any programming language, the source code (what you write) has to be in "machine code" (in Java this is called Bytecode)to be translated. This task is carried out by a so-called Compiler.

The translated code is then merged with standard libraries (these are classes and methods provided by Android). All of this is packed into a large ZIP file along with other files such as images.

To coordinate the various tasks such as compiling, copying, zipping and deleting files, a Build management tool used. In such a tool, the various processes and possible dependencies are specified in text files (often also XML), which are both easy to read and easy to change. Android Studio uses for this Gradle (other well-known tools are make, especially in the C world, or Ant in the Java world).

1.3.2 End device and emulator

In addition, there is nothing wrong with owning an Android phone or tablet to test it out. However, this is not absolutely necessary because it is so-called. Emulators that simulate an Android phone on the computer. An emulator is simulation software for a specific device, e.g. the "Google Pixel 2" smartphone.

When you start a project, you always have the option Create New Virtual Device offered. You can install new emulators there as you wish.

Install Android Studio.

Generate a new project and start Without changing anything in the project.

Install at least one at a time emulator for a current smartphone, e.g. the Google Pixel 2, and a current tablet.

Prof. Dr. Michael Kipp
Augsburg University of Applied Sciences
At the university 1
86161 Augsburg
Room J3.18
Tel: +49 821 5586 3509