Case Mobile

55
CASEmobile 71 NOVI PRISTUPI I MOGUĆNOSTI U KITKAT ANDROID 4.4 API-JU NEW APPROACHES AND POSSIBILITIES IN ANDROID 4.4 KITKAT API Zoran Kos, Zlatko Stapić SAŽETAK Android OS je danas jedan od najrasprostranjenijih OS-a na novoisporučenim mobilnim i tablet uređajima. Razlog zbog kojeg postoji interes za pisanjem o ovoj temi nije samo u tome što sve više ljudi zamjenjuje rad na računalima i laptopima za rad na mobilnim uređajima i tabletima, već što su u najnovijoj verziji Android OS-a implementirana inovativna i svježa rješenja koja korisniku omogućuju jednostavniji i brži rad, uštedu energije, uštedu vremena i manje uloženog novca. Rad prikazuje nove pristupe i mogućnosti trenutno najnovije verzije Androida 4.4. KitKat API-ja, koji još nije toliko rasprostranjen na tržištu zbog ograničene dostupnosti na određenim mobilnim uređajima i tabletima. Veći naglasak je stavljen na primjenu tehnika i tehnologija koje su usko vezane za Cloud Computing, odnosno računalstvo u oblaku. Neke od novosti su ugrađena mogućnost za ispis sadržaja prikazanog na ekranu pomoću pisača, ušteda energije primjenom senzora pokreta, novi pristup u organizaciji memorijskog i spremničkog prostora izvršavanjem aktivnosti u pozadi OS-a, smanjena mogućnost rušenja aplikacija itd. ABSTRACT Android OS is today one of the most widespread used OS on mobile and tablet devices. The reason why there is an interest in writing about this topic is not only because more and more people replace work on computers and laptops to mobile devices and tablets, it is because in the latest version of the Android OS are implemented innovative and fresh solutions that allow the user simpler and faster work, better energy, time savings and less invested money. This work presents new approaches and opportunities currently on the latest version of Android 4.4. KitKat API, which has not been so widespread on the market due limited availability on certain mobile devices and tablets. Bigger emphasis is placed on the application of techniques and technologies that are closely related to cloud computing. Some of these innovations in KitKat include integrated option to print the content on the screen using printer devices, saving energy with using motion sensors, a new approach in the organization of memory and storage tank, performing those activities in the background of the OS, the minimum possibility of demolition applications and so on. 1. INTRODUCTION The first appearance of the Android OS on a mobile device took place on the commercial market in September 2008. It is developed by the Google Corporation along with the Open Handset Alliance (OHA). Since the first version until today, Google has released 19 different versions of Application Programming Interface (API). This number is impressing considering that this was a period of less than six years. According to available statistical data on worldwide basis the number of new delivered units of the Android OS in 2013 is greater than 500 million which is equivalent to 78.60% of the worlds’ market, followed by iOS with 26.90% and WP8 with 1.60% (MobiThinking, 2014). If we are looking only on Android OS statistics (Android Developers, 2014a), currently the most common and most popular version is Android Jelly Bean (API 16, 17, 18) with a 64.40% of contributions. Second one is Gingerbread (API 10) with 17.80%, and third is Ice Cream Sandwich (API 15) with 15.00%. On fourth place is the latest version of Android 4.4. (API 19), also known as KitKat, with a 5.30% share, having its percentage doubled if compared to the second month of the year. Demand for KitKat is steadily growing as it brings new solutions, capabilities, enhanced performance, minimized fragmentation, reduced OS; but does not dramatically change graphical design in comparison with predecessor Android Jelly Bean. There are a few new features and improvements but not all of them are perfect yet. The purpose of this paper is to present new approaches and possibilities for developers in using Android 4.4 KitKat API. The paper is divided into 5 chapters. Upon the introduction presented in this chapter, the second chapter presents general facts related to this version of API and it also enumerates important new functionalities which represent the building blocks for the third, fourth and fifth chapter. The third chapter presents KitKat's new capabilities that are related to Memory management, file management, system-wide wireless printing and integration with cloud storage, and at last Android Transition Framework. The purpose of this chapter is to familiarize developers with new opportunities of applications development in KitKat. This is the most important chapter of the paper, while the forth chapter discusses differences between KitKat and his predecessor Jelly Bean observed by the user side (closely associated with the appearance and functions of a graphical interface) and the last chapter concludes the paper. 2. ANDROID 4.4. KITKAT API Smart, simple, and truly yours" - this is the slogan of the latest version of Android 4.4., popularly known as KitKat. “Nestle”, the KitKat brand owner, promotes the Android logo on the chocolate wrappers and thus promotes the new OS. KitKat was first introduced in September 2013 and was initially available only on Google’s Nexus 5 mobile devices. One of the important features of this version is

description

v

Transcript of Case Mobile

Page 1: Case Mobile

CASEmobile 71

NOVI PRISTUPI I MOGUĆNOSTI U KITKAT ANDROID 4.4 API-JU

NEW APPROACHES AND POSSIBILITIES IN ANDROID 4.4 KITKAT API

Zoran Kos, Zlatko Stapić

SAŽETAK

Android OS je danas jedan od najrasprostranjenijih OS-a na novoisporučenim mobilnim i tablet uređajima. Razlog zbog kojeg postoji interes za pisanjem o ovoj temi nije samo u tome što sve više ljudi zamjenjuje rad na računalima i laptopima za rad na mobilnim uređajima i tabletima, već što su u najnovijoj verziji Android OS-a implementirana inovativna i svježa rješenja koja korisniku omogućuju jednostavniji i brži rad, uštedu energije, uštedu vremena i manje uloženog novca. Rad prikazuje nove pristupe i mogućnosti trenutno najnovije verzije Androida 4.4. KitKat API-ja, koji još nije toliko rasprostranjen na tržištu zbog ograničene dostupnosti na određenim mobilnim uređajima i tabletima. Veći naglasak je stavljen na primjenu tehnika i tehnologija koje su usko vezane za Cloud Computing, odnosno računalstvo u oblaku. Neke od novosti su ugrađena mogućnost za ispis sadržaja prikazanog na ekranu pomoću pisača, ušteda energije primjenom senzora pokreta, novi pristup u organizaciji memorijskog i spremničkog prostora izvršavanjem aktivnosti u pozadi OS-a, smanjena mogućnost rušenja aplikacija itd.

ABSTRACT

Android OS is today one of the most widespread used OS on mobile and tablet devices. The reason why there is an interest in writing about this topic is not only because more and more people replace work on computers and laptops to mobile devices and tablets, it is because in the latest version of the Android OS are implemented innovative and fresh solutions that allow the user simpler and faster work, better energy, time savings and less invested money. This work presents new approaches and opportunities currently on the latest version of Android 4.4. KitKat API, which has not been so widespread on the market due limited availability on certain mobile devices and tablets. Bigger emphasis is placed on the application of techniques and technologies that are closely related to cloud computing. Some of these innovations in KitKat include integrated option to print the content on the screen using printer devices, saving energy with using motion sensors, a new approach in the organization of memory and storage tank, performing those activities in the background of the OS, the minimum possibility of demolition applications and so on.

1. INTRODUCTION

The first appearance of the Android OS on a mobile device took place on the commercial market in September 2008. It is developed by the Google Corporation along with the Open Handset Alliance (OHA). Since the first version until today, Google has released 19 different versions of Application Programming Interface (API). This number is impressing considering that this was a period of less than six years. According to available statistical data on worldwide basis the number of new delivered units of the Android OS in 2013 is greater than 500 million which is equivalent to 78.60% of the worlds’ market, followed by iOS with 26.90% and WP8 with 1.60% (MobiThinking, 2014). If we are looking only on Android OS statistics (Android Developers, 2014a), currently the most common and most popular version is Android Jelly Bean (API 16, 17, 18) with a 64.40% of contributions. Second one is Gingerbread (API 10) with 17.80%, and third is Ice Cream Sandwich (API 15) with 15.00%. On fourth place is the latest version of Android 4.4. (API 19), also known as KitKat, with a 5.30% share, having its percentage doubled if compared to the second month of the year. Demand for KitKat is steadily growing as it brings new solutions, capabilities, enhanced performance, minimized fragmentation, reduced OS; but does not dramatically change graphical design in comparison with predecessor Android Jelly Bean. There are a few new features and improvements but not all of them are perfect yet.

The purpose of this paper is to present new approaches and possibilities for developers in using Android 4.4 KitKat API. The paper is divided into 5 chapters. Upon the introduction presented in this chapter, the second chapter presents general facts related to this version of API and it also enumerates important new functionalities which represent the building blocks for the third, fourth and fifth chapter. The third chapter presents KitKat's new capabilities that are related to Memory management, file management, system-wide wireless printing and integration with cloud storage, and at last Android Transition Framework. The purpose of this chapter is to familiarize developers with new opportunities of applications development in KitKat. This is the most important chapter of the paper, while the forth chapter discusses differences between KitKat and his predecessor Jelly Bean observed by the user side (closely associated with the appearance and functions of a graphical interface) and the last chapter concludes the paper.

2. ANDROID 4.4. KITKAT API

“Smart, simple, and truly yours" - this is the slogan of the latest version of Android 4.4., popularly known as KitKat. “Nestle”, the KitKat brand owner, promotes the Android logo on the chocolate wrappers and thus promotes the new OS.

KitKat was first introduced in September 2013 and was initially available only on Google’s Nexus 5 mobile devices. One of the important features of this version is

Page 2: Case Mobile

72 CASEmobile

that it tends to use smaller amounts of RAM, which is not in common for most modern mobile devices. Google has devoted special attention to this by organizing "Project Svelte" (various memory-saving changes to Android framework, improved memory diagnostics, tuning knobs for Android etc.) whose results have recorded positive success that was used on KitKat API. The optimal amount of RAM is 512 MB and 340 MB is the minimum, this is reasonable because most of today’s mobile devices have this size of RAM.

Table 1 - New capabilities in Android 4.4.

New capabilites of Android 4.4.

New Memory Management

New File Management (Google cloud support)

System-wide Wireless Printing

Step counting built-in Sensors

FullScrean Read (Immersive) Mode

Smarter caller ID

Faster Multitasking (improved touchscreen)

Quick Office – working with documents

Widgets in lockscreen

New Alarm System Notification

Chrome web view

Infrared blasting (Tv remote control)

Application sandboxes

Low-power location monitoring

Bluetooth Message Acces Profile (MAP) Support

KitKat also brings new memory and file management, native cloud support, improved multitasking, widgets in lock screen, application sandboxing, low-power application monitoring and other under-hood improvements in many OS elements. The complete list of improvements is presented in Table 1, and some of them are described in next chapters.

Generally speaking, KitKat is smoothly polished and it offers a huge number of applications that are built into the OS and give great benefits to users and developers.

3. NEW POSSIBILITIES IN KITKAT

3.1 Memory Management

Android devices need memory for OS, background services, video buffers and apps. Generally, the Android OS for work with memory uses paging or memory-mapping (mmaping). When change happens in memory, whether it is about new object or the opening mmpaped site it will be recorded in the memory and the object will not be released until the release reference is set and placed in Garbage Collection. Activity Manager constantly sorts out the applications by per-process measure called oom_adj, and as memory pressure increases, the low memory killer starts killing processes. As it was mentioned earlier, KitKat is designed to work with RAM memory of 512MB, and this was achieved with behind-the-scenes improvements. For this purpose they had made revisions to remove the unnecessary backgrounds services and accessories/features that had plagued the multiple memory processing. Such optimization with new APIs effects on all installed applications for entry-level and upper-class devices and allows better multi-tasking. System memory is reduced with following (Android Developers, 2014b):

Trimmed system server and SystemUI processes (saved several MBs).

Preload dex caches in Dalvik (saved several MBs in process virtual machine).

Validated Dalvic JIT-off option (just-in-time compiler option saves up to 1.5MB per process).

Reduced per-process font cache overhead. Introduced ArrayMap, ArraySet and used

extensively in framework as a lighter-footprint replacement for HashMap, HashSet.

New API called ActivityManager.isLowRamDevice() will determine if apps run on low memory device and will act if apps have specific memory-intensive features that work poorly, so they can be turned off (some Google apps are reportedly coded to make this check). To be able to work, this API must be set true by the system property in the device makefile:

PRODUCT_PROPERTY_OVERRIDES +=

ro.config.low_ram=true

Google also gave better support to developers and Original Equipment Manufacturers (OEM) who can easily take advantage of large set of tools and accessories available to them. Thus, developers can better monitor the memory usage and work timeline with some of the following tools and activities:

new tool procstats GUI inside device settings SettingsDeveloper optionsProcess Stats

new adb shell dumpsys procstats command-line - details about memory use over time, with run times and memory footprint

new adb shell dumpsys meminfo (similar to tool-set procrank but with more clear info)

toll bugreports over adb - the services now include batterystats, procstats, usagestats and netstats.

Figure 1 - New Tool procstats GUI in KitKat (Wallat, 2013)

Page 3: Case Mobile

CASEmobile 73

shows an app run in Dalvik Debug Monitor Server (DDMS) with two services that ran once at startup. Service ExpectedQuickService is running 92% of the apps run time, while service ExpectedSlowService 0.23% of the apps run time. Just by looking at this report we can identify where the problem is.

Figure 2 - ADB shell procstats – details (Smith, 2013)

New memory management offers safer and neater work due to the use of Application sandboxes with Security-Enhanced Linux. Shortly, each app runs in a restricted environment, similar as in iOS, which has prevented the apps that perform illegal actions. Now they cannot read or change data of other Apps. On the other hand that has made a big problem in case when user or OS wants to make changes on the SD memory card and other external media with content that was created by previous API versions.

3.2 New File management

Android 4.4 offers a new, so-called, Storage Access Framework (SAF) in which users can interact with stored content as images, videos and documents. For example if user wants to send a message, UI lets user to browse files and access to recent content in consistent way across app files and providers instead of showing user a dialog to choose an application to handle content. The UI is standardized and easy to use because it combines a variety of applications as Google Drive, Dropbox, download folder with the content and gallery in one central location, together with corresponding data (see Figure 3). Developers can use and operate with centralized file management location where they can add their own storage service without making it on the vendor by vendor basis. Using SAF, i.e. cloud storage is useful on mobile devices for two reasons:

a) Internet connection becomes faster, efficient and provides an inexpensive transmission of large amounts of data.

b) Mobile devices have not yet overgrown the size of the PCs or laptops storage space.

Figure 3 – New SAF view

Client apps that need access to a provider's documents can integrate with the SAF in a few lines of code by implementing a document provider (which offers read and write access to durable files, such as files stored on a local disk, or files in cloud storage). The SAF includes the following:

Document provider Client app Picker - system UI that lets user access

documents from document providers that satisfy the client app’ search criteria.

Cloud providers or local storage services (offered by individual Android manufacturers) can use the new system by implementing a new document provider class within Android for their service, the document provider class within Android has the APIs necessary to manage, browse, read or write documents within the app from a variety of sources (Rowinski, 2013). In this way providers and clients don’t interact directly because client request permission to interact with files. Some of the features offered by the SAF are following (Android Developers, 2014c):

It lets users browse content from all document providers, not just a single app.

It makes it possible for app to have long term, persistent access to documents owned by a document provider. With this access users can add, edit, save, and delete files on the provider.

It supports multiple user accounts and transient roots such as USB storage providers, which only appear if the drive is plugged in.

For example, Figure 4 shows how a photo app might use the SAF to access stored data:

Page 4: Case Mobile

74 CASEmobile

Figure 4 - Storage Access Framework Flow (Android Developers, 2014c)

The following example shows how to load and save content with SAF on client side (request Content from a Provider). Local providers, cloud services, and external

storage use DocumentsProvider class with

abstract ContentProviders interface and are

treated in the same way providing the developer with one place to interact with the user’s content. Developers

need to call ACTION_OPEN_DOCUMENT Intent to pick

content, which signifies that we want to connect to all content providers available to the device. Calling

StartActivityForResult will launch SAF UI (see

Figure 3).

It is possible to implement filtering to this Intent based

on MimeType by specifying CategoryOpenable,

which means only content that can be opened will be returned. The code below shows filters for image results

by specifying the image MimeType:

public void searchFile(){

Intent intent = new Intent

(Intent.ACTION_OPEN_DOCUMENT);

intent.AddCategory

(Intent.CATEGORY_OPENABLE);

intent.SetType ("image/*");

StartActivityForResult (intent,

SAVE_REQUEST_CODE);

}

Code 1 – Method for filtering the documents by Mimetype

If image is selected, OnActivityResult returns the

Android.Net.Uri of the chosen file. The code

sample below displays the user's image selection:

protected override void

OnActivityResult(int requestCode, Result

resultCode, Intent data) {

base.OnActivityResult(requestCode,

resultCode, data);

if (resultCode == RESULT.Ok &&

data != null && requestCode ==

SAVE_REQUEST_CODE) {

ImageView imageView =

FindViewById<ImageView>

(Resource.Id.imageView);

imageView.SetImageURI

(data.Data);

}

}

Code 2 – User's image selection

With document URI, document can be open; here is an example of how to open a Bitmap:

private Bitmap getBitmapFromUri(Uri uri)

throws IOException {

ParcelFileDescriptor

par = gettContentResolver().

openFileDescriptor(uri, "r");

FileDescriptor file =

par.getFileDescriptor();

Bitmap image = BitmapFactory.

decodeFileDescriptor(file);

par.close();

return image;

}

Code 3 – Method for opening the selected bitmap file

In case when new file is created, user must press Save

button, OnActivityResult gets passed the URI

which can be accessed with data.Data. The Uri can

be used to stream data into the new file:

private void createFile(String type,

String fileName) {

Intent intent = new Intent

(Intent.ACTION_CREATE_DOCUMENT);

// Filter to only show results that

can be "opened"

intent.addCategory

(Intent.CATEGORY_OPENABLE);

// Create a file

intent.setType(„text/plain“);

intent.putExtra

(Intent.EXTRA_TITLE, fileName);

startActivityForResult(intent,

WHRITE_REQUEST_CODE);

}

Code 4 – Creating new document in a document provider

Persistent access to a specific file can be obtained by “taking” the necessary permissions for the Uri. The following code read and writes permissions for

referenced file by the fileUri instance (Android

Developers, 2014c):

final int takeFlags = intent.getFlags()

&(Intent. FLAG_GRANT_READ_URI_PERMISSION

|Intent.

FLAG_GRANT_WRITE_URI_PERMISSION);

// Check for the freshest data

getContentResolver().takePersistableUriPe

rmission(fileUri, takeFlags);

Code 5 – Permissions

New changes have been made in the approach to External storage, divided into two types:

Storage unique to developer app, Data shared by multiple applications

The external storage API was split out to include multiple volumes, one primary and one or more secondary (modify write permissions). Apps can’t read or write shared files on the external storage while they are running, unless they have

READ_EXTERNAL_STORAGE or

WRITE_EXTERNAL_ STORAGE permission. Write

permission implies the read permission. Therefore it is necessary to set one of these two permissions inside the application.

Page 5: Case Mobile

CASEmobile 75

3.3 New System-wide Wireless Printing and Integration with existing Cloud Storage

KitKat also brings a new feature to print documents and photos right from the phone. Google made it possible by implementing direct support for Google Cloud Print, a technology connecting printers to the cloud. It enables users to connect their phone to the printer over WiFi or Bluetooth and print selected documents in a very short period of time. However, this feature is limited to compatible printers having Cloud Print support and wireless technology built-in. It’s important to point out that before printing; each document has to be converted to PDF which is a default format for printing. In addition, printer manufacturers (OEM) can use new APIs to develop their own printing services - pluggable components that add services (vendor-specific logic) for communicating with specific types of printers that are available on Google Play. They can use the

android.printservice framework to provide

interoperability with printers from Android devices.

One of the KitKat’s important features is Google Cloud Storage, its previously existing support to use Google Drive service meant for storing and sharing documents and files (users have fast access to your app’s data from any location based on global edge-caching). A user can save and open document or file directly from cloud, without previously saving it to their phone’s storage. An app like QuickOffice (made for creating and editing Microsoft® Office documents, spreadsheets and presentations) already has the ability to connect with Google Drive.

By combining Cloud Storage and Cloud print technologies, Google enabled users to print files from their PC or tablet, and developers got a possibility to save files with high reliability and availability. The following example is dedicated to document printing possibilities of content that is currently shown on the screen. Base for that is usage of WebVIew class, which in its latest version supports HTML5 features, CSS3, V8 JavaScript engine and remote debugging of WebView content. The same was not supported in the previous versions, but now, developers got the new powerful way to develop web-based apps. New WebView is based on Chromium (open-source browser project that aims to build a safer, faster, and more stable way for all Internet users to experience the web) designed for Chrome Android browser version 30.

Figure 5 – System-wide Wireless Printing

For printing a web-page which consists of dynamic HTML content, Android Printing Framework has to be implemented within the source code of the application.

The beginning step is to change the manifest.xml

file where it’s necessary to set targerSdkVersion

to 19 and turn on the rule to enable internet

connection.

To work with objects that are related to the WebView class the following classes must be imported:

android.webkit.WebView; android.webkit.WebViewClient;

And to work with objects that are related to printing the contents, following classes should be imported:

android.print.PrintAttributes; android.print.PrintDocumentAdapter; android.print.PrintManager;

Inside the main class which extends the Activity class in the method onCreate() the following code loads the dynamic html page and creates an instance of WebView class which is assigned to WebViewClient:

WebView webView = new WebView(this);

webView.setWebViewClient(new

WebViewClient() {

public boolean

shouldOverrideUrlLoading(WebView

view, String url) {

return false;

}

@Override

public void onPageFinished(WebView

view, String url) {

webPrint(view);

myWebView = null;

}

});

webView.loadDataWithBaseURL(null, „html“,

"text/HTML", "UTF-8", null);

}

Code 6 – Loading website and creating new WebView instance

When HTML content of the web page is loaded into the

WebView object, method onPageFinished() will be

triggered that will save a reference of WebView object and invite WebPrint (view) method that opens a window for the print properties (printing panel). The document will be converted to PDF format, and this code is shown below:

webPrint(WebView view){

PrintManager printManager =

(PrintManager)this.getSystemService

(Context.PRINT_SERVICE);

PrintDocumentAdapter printAdapter =

view.createPrintDocumentAdapter();

String name = "Print Test";

printManager.print(name,

printAdapter, new PrintAttributes.

Builder().build());

}

Code 7 – Method for calling print settings

WebPrint method retrieves references to

PrintManager service, gives WebView instance and

creates a print adapter. Metod print() inside the print

Page 6: Case Mobile

76 CASEmobile

manager method pass through the job name, print adaptor and a set of default print attributes. Once the print job is instantiated, it is necessary to check whether the generated output is located at the selected location.

3.4 Android Transition framework

This chapter demonstrates how to use Animating User Interfaces with the new Android Transitions Framework (transitioning from one scene to another). In short, this Framework makes animations easier to use and make. Developers have now more control over animations, they can build complex animations with minimal working hours. This is because KitKat allows them to perform a simple property animation with one line of code and by importing libraries:

android.Transitons; android.transition.TransitionManager.

To animate showing and hiding a TextView, in case

when the button is pressed, we can use the following code example:

LinearLayout linear = (LinearLayout)

findViewById(R.id.myWebView);

Button button = (Button)

findViewById(R.id.button);

final TextView text = (TextView)

findViewById(R.id.textView);

button.setOnClickListener(new

View.OnClickListener() {

@Override

public void onClick(View v) {

TransitionManager.beginDelayed

Transition(linear);

if(text.getVisibility() !=

View.VISIBLE){

text.setVisibility(View.

VISIBLE);

}

else{

text.setVisibility(View.GONE);

}

}

});

Code 8 – Text view transition

We can get more control over the transition with Scenes. Scenes create a dynamic area in the UI using

Scenes class. Android does the rest of the work to

animate the transitions between the scenes but first developers must specify a container and several versions, or "scenes", for the XML content inside the container. To transition between two scenes, developers generally need to perform the following (Android Developers, 2013):

Specify the ViewGroup containing the UI

components you want to change. Specify the layout representing the end-result of

the change (the next scene). Specify the type of transition that should animate

the layout change. Execute the transition.

Scene object must be used to accomplish steps 1 and

2, and TransitionManager object to accomplish

steps 3 and 4. A Scene contains metadata describing

the properties of a layout that are necessary to perform a transition, including the scene's parent view and the scene's layout. For the following code example, dynamic content inside the container requires two new

Android layouts. These layouts specify only the code inside the container which in our case is

scene_activity.xml.

For proposes of this example, the two XML layouts have been created, and are included inside the container:

first_scene_layout.xml where all elements are

aligned horizontally and second_scene_layout.xml

where all elements are aligned vertically – see Figure

6. A Scene is created by

calling Scene.getSceneForLayout, passing in the

container object, the Resource ID of the Scene's layout

file, and the current Context. Below is a sample code

for MainActivity class:

Scene first_scene;

Scene second_scene;

Transition transition;

@Override

protected void onCreate(Bundle

savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.

scene_activity);

ViewGroup rootContainer = (ViewGroup) findViewById(R.id.rootContainer1);

transition = TransitionInflater.

from(this).inflateTransition

(R.transition.transition);

first_scene = Scene.

getSceneForLayout(rootContainer,

R.layout.first_scene_layout,

this);

second_scene = Scene.

getSceneForLayout(rootContainer,

R.layout.second_scene_layout,

this);

first_scene.enter();

}

public void firstScene(View view){

TransitionManager.go(second_scene,

transition);

}

public void secondScene(View view){

TransitionManager.go(first_scene,

transition);

}

Code 9 – The Main activity class showing way to manage the scene transition

First, it is necessary to add some code to load the layout

from second_scene_layout.xml file into a Scene

instance. After that we can implement the transition between the first and second scene with two methods firstScene(view) and secondScene(view).

These methods are called when one of the buttons is pressed in layout:

<Button

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Button 1"

android:onClick="firstScene" />

Code 10 – Button settings

Page 7: Case Mobile

CASEmobile 77

Figure 6 – Transition between two scenes

Their function is to load the transitions into a

TransitionManager instance and reference it in the

scene changes. Developers can also define sets of transitions programmatically with the

TransitionManager APIs. All of the transition effects

for this project are implemented within a transition XML resource file. Transition resource files must be placed in the res/transition folder of the project. With the newly created transition.xml file selected and loaded into the editing panel, the following XML content is added in a transition set that enables the change bounds transition animation with a duration attribute setting:

<transitionSet

xmlns:android="http://schemas.android.com

/apk/res/android">

<changeBounds

android:duration="1000">

</changeBounds>

</transitionSet>

Code 11 – Transition settings

With the transition file integrated into the project, any number of additional transitions may be added to the file without the need to make any further changes to the source of the activity. When specifying a transition, developers can use several predefined types defined by

subclasses of Transition, such as Fade

and ChangeBounds. If transition type is not specified a

transition type, the system uses AutoTransition by

default, which automatically fades, moves, and resizes views as necessary.

4. COMPARING KITKAT AND ANDROID JELLY BEAN

Important new things in Android KitKat, which have not been mentioned before, if compared to the previous version Jelly-Bean (API 16, 17, 18) are listed in the table 2 below:

Table 2 – Differences between Android Jelly Bean and KitKat (Allumalla, 2013)

Difference between Android Jelly Bean and Kitkat

Improved battery usage

Supports 4k resolution

Multi-sensory user experience

Supports tri-core CPU

New framework for UI transitions

Improved performance and security

Disabled access to battery statistics

Edge to Edge display provides a comfort for the user in the work

Low-power location monitoring

Audio tunneling and monitoring, loudness enhancer

More camera options: faster shooting, more accurate focusing, better balance etc.

Built-in infrared blaster support and a redesigned downloads app

The differences between these two versions at first sight may not seem to be much in the graphic design (search tab, notification bar, etc.). So for example, KitKat uses a thinner font of the text and the dominant color is white, instead of the previous Jelly Bean blue. Standard icons embedded applications are redesigned, while the Apps and Widgets tabs are not changed and the Play Store icon remains on the top-right part of the app drawer. If the call was made, and the number was not found in the user’s phone book, Google will recognize it, do a quick search and if it finds in info site, it will display basic information along with the address of the site.

There is installed possibility of restricting related data transmission over the network; under the option "Data usage". It is necessary to include a limit set and determine the allowed size of the volume. Google Hangouts (all-in-one solution) is a new messaging system, which locates in one place all discussions of SMS and MMS. Additionally there is support for high-definition video calls, so it is not necessary reach out to install industry-leading applications as Skype, Viber or WhatsApp's.

“Android KitKat has a step detector and step counter so that fitness-related apps can track when the user is walking, running, and climbing stairs. The step detector uses the accelerometer input to recognize when the user has taken a step. The step counter tracks the total number of steps since the device’s last restart. Google is working with hardware manufacturer’s work together to allow for collection and delivery of sensor data on Android device while allowing device’s processor (CPU) to stay in low-power mode.” (Chowdhry, 2013)

KitKat takes system performance to an all-time high by optimizing memory and improving touchscreen so that it responds faster and more accurately than ever before, this means that user can listen to music while browsing the web, or race down the highway with the latest hit

game, all without a hitch (Rowinski, 2013). KitKat

improves user access by providing support for system-wide closed captioning settings; the user defines which sections he want to be shown and how. With device that runs KitKat API and a Chromecast (thumb-sized media streaming device that plugs on HDTV into the HDMI port), users can enjoy in online entertainment (YouTube, Hulu-Plus, Google Play). Android supports closed captioning and subtitles, and music can be now listened longer, up to 60 hours of audio playback. In previous versions major problems were caused by working with fragments. In KitKat this was resolved with memory optimization, what helps Android to expand better and decrease crash rate.

However, even though there are many changes in the new version, the glimpse view in changes made in source code between API 18 and 19 reveal that the overall difference is 2.63%.

Page 8: Case Mobile

78 CASEmobile

5. CONCLUSION

Android 4.4. KitKat API is 19th API release for Android platform that offers new features for users and app developers. Google doesn't deliver a huge list of transformative design and feature changes, but provides support that allows developers to develop applications easier. The main feature of the new mobile OS is adaptation to lower hardware capabilities with less working memory and lower screen resolution. Within this article, the attention is placed on possibilities for app

development using new memory management, working with documents by using the new storage access framework, setting print options and content integration with Google cloud print and a new form of work with transmissions and scenes changes on the device screens.

The developers will find code examples and guidelines in using the most important benefits of presented KitKat API.

References:

1 Allumalla, A.R., 2013. Difference between Android Jellybean 4.3 and Kitkat 4.4 / [WWW Document]. Techzost. URL http://blog.techzost.com/4185/difference-android-jellybean-43-kitkat-44/2013/10 (accessed 5.1.14).

2 Android Developers, 2013. Android 4.4 APIs [WWW Document]. Android Developers. URL https://developer.android.com/about/versions/android-4.4.html#SMS (accessed 5.5.14).

3 Android Developers, 2014a. Dashboards | Android Developers [WWW Document]. Android Developers. URL http://developer.android.com/about/dashboards/index.html (accessed 4.29.14).

4 Android Developers, 2014b. Running Android with low RAM [WWW Document]. Android Developers. URL https://source.android.com/devices/low-ram.html (accessed 4.30.14).

5 Android Developers, 2014c. Storage Access Framework [WWW Document]. Android Developers. URL https://developer.android.com/guide/topics/providers/document-provider.html (accessed 5.5.14).

6 Chowdhry, A., 2013. 10 Of The Best Android KitKat Features [WWW Document]. Forbes. URL http://www.forbes.com/sites/amitchowdhry/2013/11/04/10-of-the-best-android-kitkat-features/2/ (accessed 5.12.14).

7 MobiThinking, 2014. Global mobile statistics 2014 Part A: handset market share [WWW Document]. URL http://mobithinking.com/mobile-marketing-tools/latest-mobile-stats/a#smartphone-shipments (accessed 5.8.14).

8 Rowinski, D., 2013. 10 Things Developers And Users Need To Know About Android KitKat 4.4 [WWW Document]. ReadWrite. URL http://readwrite.com/2013/11/07/android-kitkat-developers-users (accessed 5.1.14).

9 Smith, C., 2013. Android KitKat Development Tools - Procstats [WWW Document]. Double Encore. URL http://www.doubleencore.com/2013/11/android-kitkat-development-tools/ (accessed 5.12.14).

10 Wallat, J., 2013. Android 4.4 KitKat: here are the “hidden” functions - AndroidPIT [WWW Document]. AndroidPIT. URL http://www.androidpit.com/android-4-4-hidden-functions (accessed 5.1.14).

Information on authors:

Zoran Kos B.Sc

e-mail: [email protected]

Zoran Kos is 2nd

year student of Information and Programming engineering of Faculty of Organization and Informatics in Varaždin. Main interests are programming web, desktop and mobile application, new IT trends like cloud computing and mobility, making and presenting business models for startup projects. While developing new apps he focused on front-end development. He already has few smaller but successful projects behind him.

Zoran is the main contributor to this paper. He wrote the first version of the text and did coding of the presented examples.

Zlatko Stapić, PhD.

e-mail: [email protected]

Faculty of Organization and Informatics

Pavlinska 2, 42000 Varaždin, Tel: +385 42 390 820, Fax: +385 42 213 413

Zlatko Stapić, PhD., works at the Information Systems Development Department at Faculty of Organization and Informatics in Varaždin. He obtained his PhD in computer sciences from University of Alcalá (Spain) and in information sciences from University of Zagreb (Croatia) in cotutelled doctorate program. His scientific and research interests include software- and mobile applications development methodologies. He participated in more than 15 scientific and professional projects and published more than 30 scientific and professional papers. Currently he leads the Laboratory for Development and Transfer of Mobile Technologies (FOI MT-Lab). Zlatko is putting a special focus in inclusion of students in his scientific and professional activities. The published papers, projects, awards and other relevant information can be found on his personal website: http://www.foi.unizg.hr/djelatnici/zlatko.stapic.

Zlatko’s contributions to this paper are only of corrective nature. He mentored student Zoran Kos in defining the body, the structure and the style of the paper. After the first version of the paper is written, he proof-read the text and made necessary changes to make the text more focused and readable.

Page 9: Case Mobile

CASEmobile 79

PLATFORMA ZA RAZVOJ MOBILNIH APLIKACIJA – XAMARIN

Miljenko Cvjetko

SAŽETAK:

U okviru predavanja slušatelji ce biti upoznati sa osnovnim konceptima Xamarin tehnologija i alatima koji omogućuju rad na više platformi. Cilj predavanja je razbiti neke predrasude i zablude oko Xamarin tehnologija, te dati uvod u kojem se smjeru kreće krosplatformski razvoj aplikacija.

SUMMARY

Xamarin 2.0 tools brought breaking news for cross platform development of enterprise (line-of-business) applications and have democratized .net and C# programming language with a giant leap accross platform differences based on mono framework. One of the greatest breakthroughs is expected with Xamarin Test Cloud in the field of application testing which is (at this point in time) very cumbersome and not widespread.

1. UVOD

Dokument je pregled trenutačnog stanja Xamarin tehnologija za mutliplatformski razvoj aplikacija, prvenstveno mobilnih za iOS i Android, a zatim i ostalih web i desktop.

Xamarin kao firma koja je svoj razvoj definirala na mutliplatformskom razvoju prvenstveno mobilnih aplikacija, podložna je utjecajima vanjskih firmi partnera kao što su Microsoft, Apple i Google, ali i konkurencije. Ponekad se i potezi partnerskih firmi drastično odražavaju na Xamarin, pa čak i u negativnom smislu.

Glavni smjerovi razvoja Xamarin tehnologija danas je na stabilizaciji vlastitih proizvoda, te proširenju istih, ako i proširenju palete proizvoda.

2. RAZVOJNI ALATI

Jedan od najbitnijih proizvoda Xamarina su IDE alati Xamarin Studio i proširenja (addinovi) za Visual Studio koji omogućuju razvojnim programerima ciljanje više platformi i integraciju razvojnog procesa.

2.1 Xamarin Studio / MonoDevelop

Nakon poboljšanja performansi i zatim stabilizacije IDE alata Xamarin Studio pristupljeno je modernizaciji izgleda alata kozmetičkim izmjenama, no ipak bitnima za pridobivanje krajnjih korisnika.

Xamarin Studio MacOSX

Xamarin Studio Winodws

Velika većina ovih promjena vidljiva je i u open source alatu MonoDevelop na kojem je Xamarin Studio baziran.

Page 10: Case Mobile

80 CASEmobile

Xamarin Studio iOS Designer

Xamarin Studio Android Designer

2.2 Visual Studio

Na Microsoft //BUILD konferenciji Xamarin je nastupio kao jedan od vrlo jakih partnera Microsoftu, naročito nakon nedavnih promjena na vrhu Microsofta, koje su donijele nove vjetrove u odnosima.

Visual Studio je zasigurno jedan najboljih alata za razvoj softwarea i nije čudo da je odabir većine programera koji rade sa .netom. Iz tih razloga Xamarin posvećuje jedan veliki dio svojeg rada integraciji Visual Studio alata u svoje proizvode.

Visual Studio Xamarin Settings

Integracija za iOS development

iOS razvoj iz alata Visual Studio dobio je brojna proširenja, tako da je uparivanje sa Xamarin MacOSX Build Hostom mnogo transparetnije i lakše. Olakšana je dijagnostika problema, a i performanse su poboljšane, što je povezano sa radom na ostalim Xamarin proizvodima, prvenstveno runtimeu,ali i Base Class Libraries implementacijom.

Dijagnostika povezanosti Visual Studio alata sa Mac stranom za razvoj iOS i Mac aplikacija bila je problem u prošlosti. Dijagnostički dijalozi i postavke danas to jako pojednostavljuju

Visual Studio iOS Connectivity Diagnostics

Serverski dio iOS integracije imao je poteškoća zbog grešaka u implementaciji mono frameworka i runtimea na nivou socketa. Nove verzije alata i runtimea riješile su većinu problema.

MacOSX Build Host

2.3 iOS Designer

Na Microsoft //BUILD/ konferenciji, jedno od najposjećenijih predavanja i keynotea bilo je sigurno predavanja Xamarin CTOa Miguela De Icazae. Samo predavanje moralo se je prebaciti iz dvorane sa dvjestotinjak mjesta u veliku dvoranu koja je bila ispunjena sa blizu tisuću programera. U svom

Page 11: Case Mobile

CASEmobile 81

predavanju Miguel je dobio mnoge ovacije, no sigurno najveća je bila predstavljanje iOS designera u Visual Studio alatu. Koji je rezultat nastojanja smanjenja razlika među Xamarin proizvodima na različitim platformama.

Visual Studio iOS Designer

2.4 Android Designer

Visual Studio Android Designer donio je mnoge promjene, prvenstveno zakrpe i poboljšanje radnih uvjeta (performanse, neki featurei).

Visual Studio Android Designer

Namjerno prikazana greška ilustracija problema sa kojima se susreće Xamarin kao firma i korisnici Xamarin tehnologija. Uzrok greške promjena APIa od strane Googlea koje iziskuju update Android SDKa.

3. POBOLJŠANJA U PROCESU RAZVOJA

Xamarin strategija je “to delight developers” (“obradovati developere”), te se velika pažnja pridodaje razvojnom ekosustavu koji sigurno ubraja komponente kao osnovne elemente izrade aplikacija (“building blocks”), zatim testiranje koje uključuje beta testiranja, kao i automatsko testiranje UIa u Xamarin Test Cloudu.

3.1 Component store

Komponente ili kako ih još nazivaju packages, sigurno su bitni dio olakšavanja života programerima i samim time skraćenjem ciklusa razvoja i smanjenjem troškova razvoja programske podrške. To su razlozi postojanja sustava za distribuciju komponenti paketa kao što su nuget i maven, te ostali.

Xamarin je otvorio svoj komponent servis (Component Store) još prošle godine. Još ove zime broj komponenti prešao je brojku od 150 i planira se 200 krajem godine iako po trenutnom rastu taj broj bi mogao biti i 250300.

Nadalje veliki napori se ulažu u integraciju sa nugetom i nuget servisima.

3.1 Testing - End to End

Nakon što je Apple kupio beta testing kompaniju koja je razvila TestFlight i u roku od nekoliko dana iracionalno ugasio podršku za Android platformu, Xamarin je izgubio nekoliko mjeseci rada na integraciji TestFlighta u svoje IDE proizvode, a multiplatformski programeri koji koriste Xamarin tehnologije su se počeli okretati drugim beta testing platformama.

Beta Testing integracija

Da bi se olakšalo testiranje aplikacija (multiplatformski) i distribucija istih do testera tražene su alternative TestFlight servisu. Neki zamjenski ubrzano se integriraju u ekosustav Xamarina. Prvenstveno su tu servisi poput ubertester.com i slični.

Beta Testing Servis ubertesters.com

Xamarin Test Cloud

Servisi na Test Cloudu dobili su nove funkcionalnosti u vidu više uređaja, zatim daleko više informacija o samim testovima i puno prijateljskiji UI.

Xamarin Test Cloud

Page 12: Case Mobile

82 CASEmobile

4. PLATFORME

4.1 Mono runtime

Nakon produbljene suradnje sa Microsoftom ovoga proljeća veliki pomaci napravljeni su na integraciji mono runtimea sa Microsoftovim novim compilerom Roslyn projektom. Zajednički rad i postignuća prikazana su također na //BUILD/ konferenciji.

4.2 Build proces

U svrhu stabilizacije sustava radi se na razrješavanju cikličkih ovisnosti među komponentama i assemblyima. Nakon rješavanja ovih problema za očekivati je u dogledno vrijeme jednostavnije prevođenje i pakiranje

Xamarin open source proizvoda i na svim ostalim platformama, naročito Windows operativnim sustavima.

4.3 Core assemblies

Aktivnosti oko BCL (Base Class Library) prvenstveno je usmjeren na rješavanje grešaka i problema, te reorganizaciji strukture projekata koji bi trebali riješiti cikličke ovisnosti, te smanjiti broj međusobnih ovisnosti, a samim time olakšati build procese na svim platformama.

4.4 ASP.net

Nakon objave da je nova verzija Microsoftove web platforme ASP.net postala open source, te da je mono platforma dodana u testnu matricu za ASP.net za očekivati je da mnoge ASP.net web aplikacije presele na ne Windows platforme, prvenstveno Linux. Ovo je i do sada bilo moguće, doduše ne u potpunosti i ne bez velike muke i znanja.

Self hosted owin, katana aplikacije na Linux platformama nisu daleka budućnost i za očekivati je veliki broj Internet of Things (IoT) aplikacija koje bi trebale koristiti ove platforme na Windows i Linux embedded sustavima.

5. ZAKLJUČAK

Ovo je bio samo jedan površinski pregled s visokog o trenutačnom stanju tehnologija koje razvija Xamarin na mobilnom, ali i na serverskom dijelu u suradnji sa svojim partnerima / prvenstveno Microsoftom.

Podaci o autoru:

Miljenko Cvjetko

e-mail: [email protected]

e-mail: [email protected]

http://holisticware.net

http://xamarin.com

HolisticWare is startup company whcih develops mobile apps with .net technology. In 2011 teams top prioities were developing with Mono technology (open sourced .net port) to non-indows platforms, especially iOS and Android.

Page 13: Case Mobile

CASEmobile 83

KORIŠTENJE ANDROID ANNOTATIONS I ACTIVE ANDROID RAZVOJNIH OKVIRA

USING ANDROID ANNOTATIONS AND ACTIVE ANDROID DEVELOPMENT FRAMEWORKS

Alen Huskanović, David Ante Macan

SAŽETAK:

Android je danas najpopularniji operacijski sustav za mobilne platforme. No, unatoč svojoj popularnosti, nativan razvoj aplikacija za Android zna biti poprilično dugotrajan muktorpan posao, te je ponekad čak i za jako male i jednostavne aplikacije potrebno ubaciti puno koda. Upravo iz tog razloga, danas se javlja sve više i više novih i inovativnih open-source rješenja koja smanjuju taj problem iz pojedinih aspekata. Android Annotations i Active Android upravo su takva rješenja koja se danas koriste sve više u sve ozbiljnijim projektima. Active Android ORM je alat koji uvelike olakšava manipulaciju bazom podataka, dok je Android Annotations razvojni okvir koji nam pruža skraćeno pisanje mnogih popularnih dijelova koda koji se s vremenom i veličinom aplikacije sve više gomilaju. Oba ova razvojna okvira koriste anotacije u programskom jeziku Java, te uvelike skraćuju pisanje koda, što omogućuje developerima da se više fokusiraju na inženjering i dizajn aplikacije, nego na samo pisanje koda.

ABSTRACT:

Nowadays, Android is the most popular mobile operating system. But, although its popularity, native Android application development can be quite time and energy consuming work. Sometimes, it is necessary to write a lot of code even for small and simple applications. That is exactly why there are more and more various new open-source solutions that take care of those problems from different aspects. Android Annotations and Active Android are such solutions that are being more and more used in lot of serious projects. Active Android is an ORM tool that eases database manipulation a lot. On the other hand, Android Annotations is an framework that offers us shortened writing of the popular parts of code, and increases the complete code readability. Both of these frameworks use annotations in Java programing language and reduce the code writing a lot, which enables the developers to be more focused on engineering and design of the application, instead on focusing on code writing.

1. INTRODUCTION

The successful development of mobile applications is largely dependent on the quality of written code. Unfortunately, today the code is increasing rapidly and it should be reduced. Specifically, regarding the development for Android, very often for some general things there must be code written that is already mostly predefined and in the high ratio it does not change from application to application. By writing such code, developers spend precious time reading it and it becomes cumbersome and unreadable.

From the above mentioned reasons, some developers are trying to make their own development frameworks that will replace the entire predefined code with only a few lines of their own, and with that save a lot of time.

The aim of this paper is to introduce developers who develop applications for Android that there are developmental frameworks that can help them with the speed and quality of development of mobile applications.

This paper is divided into three chapters; in the first one, Active Android development framework will be explained, which is ORM for Android. The next chapter is intended for Android Annotations development framework, which with the help of Java Annotations helps in reducing a lot of code. The final chapter is intended for the comparison of native approach with the usage of a development frameworks where the

advantages will be shown, as well as the disadvantages of using those very same frameworks.

2. ACTIVE ANDROID

2.1 Introduction to Active Android

As an Android operating system framework, Active Android is an ORM (object relational mapper) library. Active Android allows you to manipulate data in database over SQLite database management system. It provides quick and easy usage without using any of the SQL queries directly. Developers don't even need to know SQL to use this framework[1]. Active Android provides usage with the records in the database via objects, so that the developers don't have problems with conversion of tabular entries into objects and vice versa. Model class represents a table and class instance represents a record in table. Database management with Active Android is much simpler and faster because developers can create a class and with annotation tell the system that that class represents table in the database. Active Android does all the work around the database setup so that the developers don't have to write CRUD methods themselves.

Nowadays the Active Android is one of the most useful frameworks for programming applications on Android operating system as shown by the increasing number of users. The source code of the framework can be found at Github where everyone can take it and use it [2].

Page 14: Case Mobile

84 CASEmobile

2.2 Using Active Android

In this section, we will create a very simple mobile application with database for chocolate sale. We will create this database in both standard and Active Android way. Let’s create a use-case here and say that we wish to delete the first receipt with a salesman “Mario” who sold the chocolate “Dorina”.

For that, we need to do the following steps:

Create tables and model classes Insert required data Read the inserted data Print the data to the screen

Native approach:

Using standard approach without Active Android, we usually need to create DatabaseHelper class that contains methods and attributes for setting up and updating the database. Using this class, we need to specify both database name and database version, alongside with adding SQL code for creating and dropping every single table that our database will contain.

To improve efficiency and reduce typo errors, we usually put the CREATE TABLE string into the class that represents the table that is to be created. We created the SalesmanSQL.java and ReceiptSQL.java in the same manner. After the representative model classes were created, we need to create DatabaseHelper class that helps us connect to the database and creates tables using previously mentioned CREATE TABLE strings.

And final class that we need to create is called DatabaseAdapter. This class provides us with all the CRUD methods for our tables. Unfortunately, coding of this class usually takes quite a lot of time. The problem with database adapter is that it is usually very large, because we need to add qute a lot of code for each table individually. After setting up the database, we can start using it.

Active Android approach:

To use Active Android, we just need to setup few things and we are ready to code. First of all, we need to override default Application class for our app and add a reference to it in the manifest file. Besides that, we also need to write database name and version inside the manifest file. We do this like in the following example:

AndroidManifest.xml ... <application android:allowBackup="true" android:name="CaseApp" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <meta-data android:name="AA_DB_NAME"

android:value="CaseApp.db" />

<meta-data android:name="AA_DB_VERSION" android:value="1" /> ...

Now we are ready to start coding our database. Instead of creating DatabaseHelper and DatabaseAdapter classes, we just need to add few modifications to the existing model classes:

Receipt.java

@Table(name = "receipts") public class Receipt extends Model { @Column(name = "chocolatte") private Chocolatte chocolatte; @Column(name = "salesman") private Salesman salesman; @Column(name = "time") private String time;

public Receipt() { } ...

As shown above, using Java’s annotation processing tool, Active Android allows us to define our table inside it’s appropriate model class. Notice also that this time we didn’t add the id attribute in our class. That is because Active Android itself handles it and Model class allows our classes to inherit that attribute. As for the foreign keys, Active Android improves that part as well. If we put into a column an attribute that is a child of Model class, Active Android automatically creates foreign key for that column. Another noteworthy fact is that Active Android provides us a way to just query the database and it handles the whole “linking and communication” process with the database, which allows the developer to focus more on designing and developing, instead of mindless coding.

Receipt.java ... //Some query methods

public static Receipt readReceiptById(long id) { return new Select().from(Receipt.class).where("Id =? ", id).executeSingle(); }

public static List<Receipt> readAllReceipts() { return new Select().from(Receipt.class).execute(); }

public static Receipt readReceiptForSalesmanAndChocolatte(Salesman salesman, Chocolatte chocolatte) { return new Select().from(Receipt.class).where("salesman =? AND chocolatte =? ", salesman.getId(), chocolatte.getId()).orderBy("Id").executeSingle(); } ...

Finally, we can show how to use the database:

Creating chocolatte, salesman and receipt: Chocolatte dorina = new Chocolatte("Dorina", 4.00); dorina.save(); Salesman mario = new Salesman("Mario", 22); mario.save(); new Receipt(dorina, mario, currentDate()).save();

Figure 1 - ER model of example database

Page 15: Case Mobile

CASEmobile 85

Reading that receipt from the database Receipt receipt = Receipt.readReceiptForSalesmanAndChocolatte(mario, dorina);

Deleting that receipt from the database

receipt.delete();

3. ANDROID ANOTATIONS

3.1 Introduction to Android Annotations

Lately, among Android developers is discussed the concept of Diet Driven Development, and anyone who is familiar with this concept is also familiar with Android Annotations framework which will be presented in this chapter[3].

Android Annotations is a development framework for the Android operating system which reduces the unnecessary code; using Java annotations, developers can show their intent and let Android Annotations generate the plumbing code at compile time[4].

This development framework helps developers in writing neat and readable code, and thus allows faster production and faster debugging while developing Android applications. Android Anotations is free to use, and full source code is available on GitHub[5].

3.2 Using Android Anotations

In this section, we will try to induce some of the practical usages for Android Annotations framework. Let’s start with the first class that is created when the project is generated. That is MainActivity class that (usually) extends Activity. Every Android developer knows that,

by default, every Activity has its onCreate method

which gets called every time the activity gets created. But the problem is that this method looks almost always the same, but it takes couple of lines of code just to write it and specify the layout for the activity. Using Android Annotations, we can clean that code as shown in next example: @EActivity(R.layout.activity_main) public class MainActivity extends Activity { @AfterViews

void main() { // Do something

} }

As shown in the example above, it is very simple to specify the designated layout for the activity, as well as the method that is to be invoked after activity gets created. If our activity is to be used with Android Annotations, we must provide an annotation @EActivity (as shown in the example above). Using this analogy, it is clear that @AfterViews annotations specifies the method that is called after the activity is created. This is a very simple, but effective demonstration of Android Annotations power.

Another thing in Android that can easily increase the code amount a lot (especially if it is done multiple times) is the process of binding xml elements together with the Java variables. Using native approach, we need to take following steps: Create designated View variable Specify that the variable is to be used for View

element with certain id Cast the View if necessary

Using Android Annotations, this is done simply by Adding @ViewById annotation as shown in the next example: @ViewById

TextView txtLabel;

The code above automatically binds View element with id “txtLabel” from given layout to the txtLabel variable. Fortunately, Android Annotaions can detect variable name and recognize it as an id, but we aren’t forced to use that naming convention. If we decide to call id different than the variable name, we can simply add an annotation attribute with the elements id like this: @ViewById (R.id.txtMyId)

There are plenty more situations like this in which Android Annotations provide a simple and elegant solution. For example, there is a @Click annotation which is used to handle click events for designated views, @ItemClicked annotation that handles list item click events, etc.

Another great example of necessary native complex code is the AsyncTask. By default, AsyncTask is used for safe and proper synchronization of the background thread and UI thread. The only problem is that it is relatively large and complex to write. Using AndroidAnnotations, this is solved in again, very simple and elegant way. Simple way of replacing AsyncTask with Android Annotations is shown below: @Background

private void doInBackground() { // Do some background work

updateUIThread(); } @UiThread

private void updateUIThread() { // Do some UI work

}

So, the big and complex AsyncTask is replaced with two simple methods. When called, “doInBackground” method will do its work in background thread and update UI Thread when done.

There are many more annotations in this framework that aim to ease native Android development a lot. Some of the things that are improved a lot with this framework are:

Rest API implementation (@Rest, @Get, @Post, …)

Activity saved instance state (@InstanceState)

SeekBar events (@SeekBarProgressChange, @SeekBarTouchStart, …)

Text change events (@TextChange)

Options menu (@OptionsMenu, @OptionItem, …)

And many more….

4. DISCUSSION

4.1 Comparing Active Android and Android Anotations with native approach

As stated before, both Android Annotations and Active Android frameworks are used for reducing the amount of code needed for implementing some functionalities in our Android applications.

Android Annotations framework makes our code more readable and easier to use and understand by replacing (not removing) a lot of code that is either generated or

Page 16: Case Mobile

86 CASEmobile

necessary for the right implementation. A lot of Android developers that use native approach agree that they often find themselves losing quite a lot of time just for setting up and preparing some functionalities.

As for the Active Android framework, not only does it reduce the code needed for implementation, but it also allows us to design our database using Object-Oriented approach, without having to think a lot about modeling the database itself.

4.2 Advantages and disadvantages

Using a framework in application development along with benefits also brings a number of disadvantages and limitations. Usually, the benefits are far above the limit, and in most cases development frameworks are worth using.

Using Active Android and Android Annotations developers get a great set of advantages. Both developmental frameworks are easy to use and maintain, and perhaps one of the most important benefits is the reduction of errors. It is widely known that errors are mainly due to human factors, and by using development frameworks the vast majority of the code is automatically generated and developers are not obliged to write these parts, which reduces the probability of one of them to make a mistake.

Both development frameworks have a lot of influence on the number of lines of code, and it goes in the direction of Diet Driven Development. According to some informations, using just Android Annotations in average reduces the average number of lines of code for 42%, and using Active Android gives even more reduction[3]. Code written using a development framework is in most cases more readable, and easier to determine later why is some section of code used.

The disadvantages the developers face using development frameworks are largely related to the inability of customizing individual parts, while Active Android and Android Annotations offer these possibilities. These problems are eliminated by an open source development framework that anyone can

customize to their liking. With all attempts to eliminate drawbacks, there are still some that the community is trying to solve, for example in Active Android function for adding records to a table is void, and the only way to check whether a record successfully entered or not requires selecting the base immediately after entry. Development frameworks are quite large, and it is not easy to manage them while trying to customize.

Active Android as an ORM does support only the code-first approach, so a base model (classes) can not be made from tables[6].

Each development framework, including these two, requires configuration and customization of a project to their mode before it can be used at all, and to inexperienced programmers it can add complications with the development which leads to droping out the development framework at the first step, the configuration.

5. CONCLUSSION

This paper briefly summarizes the advantages and disadvantages of using frameworks such as Android Annotations and Active Android for native android development. Android is a tremenduous platform, and it's development is great. But, as allways, there is room for improvement. While developing applications in a standard way, developers often have to add or generate relatively large ammounts of code to acomplish some really trivial functionalities. But with usage of additional frameworks, as shown in this paper, that code could be easilly reduced and it's readibility improved, which is often a very important factor.

To conclude this paper, we will add a quote from Robert C. Martin to show how important clean and readible code is:

„The ratio of time spent reading [code] versus writing is well over 10 to 1 [therefore] making it easy to read makes it easier to write.“ [7]

References:

1 “ActiveAndroid Guide,” CodePath. [Online]. Available: http://guides.thecodepath.com/android/ActiveAndroid-Guide#overview. [Accessed: 21-May-2014].

2 M. Pardo, “Active Android source code,” 21-May-2014. [Online]. Available: https://github.com/pardom/ActiveAndroid.

3 P.-Y. Ricau, “Diet Driven Development,” Devoxx. [Online]. Available: http://www.devoxx.com/display/DV12/Android+DDD+(Diet+Driven+Development)! [Accessed: 16-May-2014].

4 “AndroidAnnotations offical site,” AndroidAnotaions. [Online]. Available: http://androidannotations.org/. [Accessed: 21-May-2014].

5 “AndroidAnnotations source code,” Github. [Online]. Available: https://github.com/excilys/androidannotations. [Accessed: 21-May-2014].

6 Ž. Plesac, “Infinum Talks - Active Android.” [Online]. Available: http://www.slideshare.net/Infinum/infinum-android-talks-02-activeandroid. [Accessed: 21-May-2014].

7 R. C. Martin, Ed., Clean code: a handbook of agile software craftsmanship. Upper Saddle River, NJ: Prentice Hall, 2009.

Information on authors:

Alen Huskanović

e-mail: [email protected]

Faculty of Organization and Informatics

Alen Huskanović is a regular student of the third year of undergraduate study Information Systems at the Faculty of Organization and Informatics in Varazdin. He has participated in various national and international competitions, among which stands out IEEEmadC international competition for the design of mobile applications where he won first prize.

Page 17: Case Mobile

CASEmobile 87

Actively working on the system PEAS with whom he came to Croatian finals of Microsoft Imagine Cup. He is primarily engaged in the development of applications for the Android operating system.

David Ante Macan

e-mail: [email protected]

Faculty of Organization and Informatics

David Ante Macan is a third year undergraduate student of Information Systems at Faculty of Organization and Informatics. He has participated in various competitions, including the Croatian Microsoft Imagine Cup finals, won the best design award at IEEEmadC contest, won the third place at Infinum student Hackathon 2014, etc. His main area of interest is mobile development, especially Android. He is actively working on several projects, including the Personal Exam Assistant (PEAS) project at Faculty of Organization and Informatics. He is also a member of IEEE Institute and is one of the student coordinators and founders of the Laboratory for mobile technologies (MT Lab) at Faculty of Organization and Informatics.

Page 18: Case Mobile

88 CASEmobile

Page 19: Case Mobile

CASEmobile 89

PRIMJENA I PREDNOSTI NOSQL BAZA PODATAKA

USING THE ADVANTAGES OF NOSQL DATABASES

Mario Novoselec, Denis Pavlović, Milan Pavlović

SAŽETAK:

Relacijske su baze danas temelj poslovanja velikog broja modernih organizacija. Težnja organizacija za skalabilnošću sustava i trend razvoja Web 2.0. aplikacija uvjetovali su razvoj NoSQL (Not only SQL) baza podataka. Drugi tip motivacije ogleda se u agilnom pristupu razvoju s naglaskom na smanjenje kompleksnosti i povećanje brzine razvoja. S obzirom na velike troškove u određenim domenama implementacije relacijskih baza podataka, NoSQL baze podataka nastoje smanjiti troškove održavanja skalabilnosti i pružiti jednostavna rješenja za distribuciju i particioniranje modela podataka. Ovaj će rad predstaviti danas najkorištenije tipove NoSQL baza podataka pozicionirajući ih direktno u okvire primjene s naglaskom na direktnu usporedbu u konkretnoj domeni s relacijskim bazama podataka.

ABSTRACT:

Relational databases are one of the underlying parts of modern organizations. Need for system scalability and development of Web 2.0. applications are one of the main drivers for NoSQL (Not only SQL) database rise. Another type of motivation is represented by trend of agile development with emphasis on reducing complexity requirements and increasing speed of application development. Considering higher costs in some areas of relational database system implementation, NoSQL databases are trying to directly reduce costs of maintaining scalability and offer solutions for effortless distribution and partitioning of data models. This paper will introduce the most used NoSQL database systems by positioning them directly into the scope of usage with emphasis on direct comparison with relational databases.

1. INTRODUCTION

The NoSQL trend has appeared as a response to massive cost of storing and manipulating data in classical relational database systems. Another benefit of NoSQL movement was flexibility of data modeling and distribution. ''Relational databases provide a variety of features and strict data consistency. But this rich feature set and the ACID properties implemented by RDBMSs might be more than necessary for particular applications and use cases. As an example, Adobe’s ConnectNow holds three copies of user session data; these replicas do not neither have to undergo all consistency checks of a relational database management systems nor do they have to be persisted. Hence, it is fully sufficient to hold them in memory.''[2] NoSQL systems share several key characteristics. ''When compared to relational databases, NoSQL systems are more scalable and provide superior performance.’’[1]

With this approach, NoSQL databases are trying to resolve some of the most common relational database problems.

Since most of Web 2.0. applications are agile, NoSQL databases tend to be very flexible as opposite to relational databases. For instance, in most NoSQL systems you do not have fixed database schema structure and there is no need for forcing unique data model. These types of data modeling are applicable to applications that generate high amount of inconsistently structured data (e.g. Web blogs, etc…).

Jonathan Ellis from Rackspace defines three problems of relational databases: [3]

1. Data scalability 2. Single server performance

3. Strict schema design

This paper will describe main benefits and key concepts of NoSQL databases with concrete examples in areas of industry and science. Also, this paper will try to present some of the NoSQL database downsides and their affect to organizational and similar environments.

2. DATA MODELS

One of the main differentiation between relational and NoSQL databases is the data model. Modern NoSQL databases can be divided into three main categories.

2.1 Document Model

In this type of databases, data model is represented by documents. Documents have JSON (JavaScript Object Notation) like structure used for storing and traversing through data.

In relational databases one record is scattered through different columns, while in document data model one record is represented with single document (object). In that way, document data model provides an object-oriented approach to data representation.

Documents do not have strict schema structure and can contain different type of fields. Every field can contain different type of data such as date, binary, array or string. ‘’This flexibility can be particularly helpful for modelling unstructured and polymorphic data. It also makes it easier to evolve an application during development, such as adding new fields. Additionally, document databases generally provide the query robustness that developers have come to expect from

Page 20: Case Mobile

90 CASEmobile

relational databases. In particular, data can be queried based on any fields in a document.''[1]

This paper will focus on one of the most popular document database used today, MongoDB. According to Mongo Inc. there is a wide variety of document database usage, especially in science.

The European Organisation for Nuclear Research, also known as CERN, is using MongoDB for solving problem of storing high amount of differently structured data. ''At this scale, the information discovery within a heterogeneous, distributed environment becomes an important ingredient of successful data analysis. The data and associated meta-data are produced in variety of forms and digital formats. However, users want to be able to query different services and combine information from these varied sources. However, this vast and complex collection of data means they don’t necessarily know where to find the right information or have the domain knowledge to extract this data.''[4]

The choice of NoSQL document model database was logical in this example mainly because there is no rigid data structure nor data persistency. Because data is not structured equally and there is a need for fast searching through big set of data, document model database can support that kind of requirements in fast and flexible way.

Main alternative to MongoDB as a leading document oriented database, is a CouchDB which is a database oriented towards Web applications. ''CouchDB’s design borrows heavily from web architecture and the concepts of resources, methods, and representations. It augments this with powerful ways to query, map, combine, and filter data.’’[5]

2.2 Key-Value Model

The most basic type of NoSQL databases are key-value stores. Every data instance has its own unique key which is used to access associated value. These kind of data structure is very similar to dictionaries found in some higher programming languages.

This paper will briefly introduce one of the most advanced key-value databases on the market called

Redis. ‘’Since most key value stores hold their dataset in memory, they are oftentimes used for caching of more time intensive SQL queries.''[2]

This paper will briefly show some example of key-value model and some basic set of operations. In Redis, we can specify our database insert by using SET command:

SET user_role 'administrator'

Data insertion uses valid key-value syntax and allows ease of access to any value in a data set:

GET user_role

One of the most important use case of Redis database implementation is Pinterest, multinational social network. One of the main characteristics of social networks is ability to follow other users and their interest. Pinterest tried to implement graph structure as seen in Facebook or Twitter with millions of nodes representing users.

‘’For example, if Andrea follows Bob, she’ll follow all of his boards, and if he creates a new board, she’ll automatically follow that board. If Andrea follows Bob’s Recipes board, she’ll see all of his pins from that board in her home feed. Andrea will also be listed as a follower

of that board. We term the board followers as implicit followers (while the previous type of user-to-user follower is an explicit follower).’’[7]

That kind of in-depth analysis of users behavior had major requirements towards data caching for real-time user analysis. Relational databases quickly reached their limits because of graph caching specifics. ‘’Caching the graph data is hard because the cache is useful only if the entire subgraph of a user (vertex) is in cache, however this can quickly result in an attempt to cache the entire graph!’’ [7]

Pinterest engineering team found solution in Redis SortedSet data structure. SortedSet is data structure very similar to standard set represented by binary-safe string but with addition of operation to return items in order. Pinterest used Redis for storing graphs which were sharded by ID of a single user. Major disadvantage was single threaded nature of Redis database which was overridden by running multiple instances of Redis on each CPU core.

By using Redis, Pinterest engineering team managed to implement advanced graph structure for user analysis:

Figure 1: Pinterest graph structure for user analysis [7]

By moving away from relational databases, Pinterest gained some advantages in scalabilty and efficiency of existing infrastructure. ‘’In the end, when we migrated away from the existing sharded MySQL cluster, we saved about 30% IOps.’’

2.3 Column Oriented Databases

Column oriented NoSQL databases use multidimensional sorted map as main structure for storing data. In this kind of structure there is random amount of key value pairs that can be stored in each record. ''Each record can vary in the number of columns that are stored, and columns can be nested inside other columns called super columns. Columns can be grouped together for access in column families, or columns can be spread across multiple column families.''[1]

Because of their column oriented structure, column databases are very similar to relational databases. Main advantage of NoSQL column databases are ability to store data without fixed schema and reducing amount of null values to minimum. If there is a data structure with many different types of attributes, relational database would have null value for every instance of data that is not known. In column oriented database data would simply be stored in one row if there is a need for it.

This paper will introduce Casandra as one of the most used NoSQL column oriented databases. In Casandra

Page 21: Case Mobile

CASEmobile 91

data structure can be easily represented by group of columns called column family:

CF= user_role

rowKey1 role permission dateCreated admin All 2012-1-11 rowKey2 role permission dateCreated user Basic 2013-11-13

Every row instance has unique identifying key. There is also column based structure for storing data which can be independent of fixed schema.

One of the most interesting case studies involving Casandra was Bazaarvoice. Bazaarvoice is a service for collecting user generated content and analyzing information gathered through different media. Bazaarvoice’s case was oriented towards cloud friendly systems and ease of maintaining clustered database systems. ‘’Next, we needed a database that allowed for easy capacity expansion (especially write capacity) by simply adding new machines online. Having multiple data center support was also a very big deal, especially where we can write to multiple data centers at the same time.’’[9]

Main disadvantage of MySQL as a classical relational database was impossibility to scale according to write capacity growth. Bazaarvoice uses Casandra to store all of customers metadata into single data catalog. That means that every customer becomes single key with different column structure depending on gathered information.

These kind of data structures can be optimized for quick data access because of easy to maintain data structure.

2.4 Scaling NoSQL Databases

Most of NoSQL databases are used across multiple systems to distribute large amount of data. NoSQL databases like MongoDB are using sharding to control process of partitioning data on multiple servers. A shard can be easily described as one or more instance of servers in a massive cluster used for distributing any subset of data. The goal is to distribute data evenly across multiple shards by redistributing them. ‘’Relational databases (traditionally) reside on one server, which can be scaled by adding more processors, more memory and external storage. Relational database residing on multiple servers usually uses replications to keep database synchronization.''[11] NoSQL databases are oriented towards cloud and multiple server scalability with focus on ease of maintaining partioned data. Data is transfered on multiple shards in range of key-value pairs. Each shard is only responsible for a specific range of data. Using this strategy, querying certain data range can be done in a fast and efficient way.

In order to maintan high performance of data access over multiple shards, NoSQL databases can compromise data integrity in a way that data can easily be lost or overwritten.

3. SCALING ON CLOSED BENCHMARK

In work [12], some performance and scaling comparison between RDBMS MySQL and NoSQL system MongoDB was described. Authors of related work built the benchmarking harness using C programming language and latest stable drivers for each database system. As they describe on p. 12., their benchmarking harness

measured the time required to complete a set number of transactions as each transaction on its own is negligible. For calculating the queries per second formulas on fig. 2. were used.

Figure 2. Metrics used in benchmark [12]

As they furthermore describe on p.12-13, database schema used in benchmark was designed and modeled to support a music application which would use different algorithms to suggest songs to users according to their tastes. The normalized schema was made for MySQL database implementation and shown on fig. 2 . Due to fact that MongoDB does not support complicated operations such as JOINs, some compromises were made. Final schema for MongoDB was showed on fig. 3. Details of queries (simple and complex), other statements and configuration of both databases can be found in [12], p. 15.-19. Every SQL statement had it’s equivalent for MongoDB.

Figure 3. MySQL schema used in benchmark [12]

Figure 4. MongoDB schema used in benchmark [12]

Authors in [12] made several conclusions about implemented benchmark. MongoDB could handle more complex queries faster because it worked with simpler schema, but with the cost of data duplication. Despite observed performance gain in complex queries, when queries included nested SELECTs MySQL performed best. In last type of complex query which contained two JOINs and subquery, MongoDB had advantage over MySQL due to Mongo’s use of subdocuments. “This advantage comes at the cost of data duplication which causes an increase in the database size. If such queries are typical in an application then it is important to consider NoSQL databases as alternatives while taking

Page 22: Case Mobile

92 CASEmobile

in account the cost in storage and memory size resulting from the larger database size.” [12], p. 35-36.

Write operations were also considered in above benchmark. MySQL performed better in data deletion and authors of [12] claim this is logical because MySQL performes better in simple search queries. Searching and deletion are connected because deletion requires finding the record to be deleted first. MongoDB performed better in insertions. Both databases had a linear trend in this test.

Mentioned authors also emphasized the use of different configurations for nodes and threads. “This part of the benchmark required running the benchmarking harness on 1, 2 and 3 nodes with multiple numbers of threads in order to test how the databases performed with multiple connections.” [12], p 36. Although databases behaved differently depending on the query complexity, at higher numbers of connections the performance (queries per second) appeared to converge.

Finally, they concluded that two databases behave differently according to the type of queries, so the choice of which database to use lies on the type of application the system will be using. When using MongoDB as database system, it is important to have on mind that this database system results with increased database size. “Despite the indication that the performance penalty on both databases is small depending on the database size it is nonetheless an important factor when considering the type of queries which will be performed by applications” [12], p 36.

4. NoSQL POSSIBILITIES ON MOBILE PLATFORMS

Today, mobile applications have some specific and common requirements about data persistence and processing. Currently, mobile applications are one of the most dynamic areas of Information Technology. In similar way, demand for tablets and smartphones has created a huge market for mobile applications developed today. “Also many Business Information Systems/ Business Informatics undergraduate and master programs introduced in their curriculum courses related to mobile devices and applications”[13].

Most of mobile applications today require a persistent data layer, which is also one of the features of web applications. Currently, mobile applications share quite a few features of client -server web application architecture, but there is one striking difference between mobile and web application databases concerns. While on one side web applications have a larger scale and lots of resources on disposal, on the other hand mobile applications have lesser scale and lesser resources on their disposal (processing power) .

There had been huge amount of interest about NoSQL data stores in last couple of years. Primarily NoSQL data stores are used inside big web applications which have needs for storing huge amounts of information about user interactions and similar data. On the other side as mobile platforms and hardware are being developed, storage and performance of devices powered with same platforms and hardware is rapidly catching up desktop platforms. With that demand for solutions like NoSQL databases on mobile devices is increasing and currently used in some mobile applications. Community of developers is trying to embrace NoSQL on mobile platforms in a way of creating special libraries for mobile NoSQL databases.

One of those is Android Couchbase library for using and storing data into popular document NoSQL database CouchDB. In that way, mobile application developers can embed CouchDB database into their Android application.

4.1 Querying NoSQL Databases

In classical SQL databases, schemas are composed of one or more tables where each of the tables is composed internally with fixed structure for table rows. Opposing to tables, MongoDB database is composed of collections in which each of the collections is composed of one or more documents. Also each of those documents that together create collections can have completely different data structure. On SQL side there are few options that can’t be found inside MongoDB and vice versa. For example, users could have roles and roles could be referencing users while on MongoDB side there wouldn’t be any referencing between collections. Both of databases support querying but in a bit different ways. SQL databases support them in terms of SQL queries. On the other side NoSQL database or MongoDB in this case supports querying in terms of built in functions. Each of these functions can be used to manipulate data in different ways depending of the context of data. One important notice about MongoDB in this context is that it “permits finding documents with no value declared for an attribute”[13]. Example for this case is an region of one country, if it’s not declared it won’t be found, unless we explicitly specify the $exists attribute. SQL databases do not have equivalent for this query as such query couldn’t be possible because of sharing structure between all the rows in table. Problem on the other side is that as queries become more and more complicated MongoDB database shall extensively use variables inside of one query. Disadvantage of MongoDB query approach is that there are no subqueries, but that problem can be solved via in operator. Special operators for nesting queries differentiate NoSQL approach and guarantee most of SQL query possibilities.

db.roles.find({user:{$in:[‘admin’,’moderator’]});

5. CONCLUSION

NoSQL trend is emerging as a valid relational database alternative for specific use. It is very important to analyse important aspects of different NoSQL data models and include them in system requirements. As mentioned, NoSQL databases behave different according to size of data set and amount of operations to execute. Flexible schema approach and functional query structure manage to increase performance and give effortless ways for data partitioning.

Relational SQL databases are focusing on rigid structure with defined data types for storing data. In that way, they are not suitable for use in environments that are generating massive amounts of differently structured data. With growth of Web 2.0. application usage there are a lot of requirements for NoSQL databases.

Page 23: Case Mobile

CASEmobile 93

References:

1 MongoDB Inc., “Top 5 Considerations When Evaluating NoSQL Databases”, June 2013.

2 C. Strauch, “NoSQL Databases”, Stuttgart Media University, 2004, pp. 1–45.

3 J. McKEnna, “NoSQL Ecosystem” [Online]. Available: http://www.rackspace.com/blog/2009/11/09/nosql-ecosystem/. [Accessed: 16-May-2014].

4 MongoDB Inc, “CERN CMS” [Online]. Available: http://www.mongodb.com/customers/cern-cms. [Accessed: 16-May-2014].

5 The Apache Software Foundation, “Why CouchDB?” [Online]. Available: http://docs.couchdb.org/en/latest/intro/why.html. [Accessed: 14-May-2014].

6 K.Seguin, “The Little Redis Book”, January 2012.

7 A. Khune, “Building a follower model from scratch” [Online]. Available: http://engineering.pinterest.com/post/55272557617/building-a-follower-model-from-scratch [Accessed: 14-May-2014].

8 “NoSQL - Not only SQL” [Online]. Available: http://scriptandscroll.com/2011/08/21/nosql-not-only-sql-introduction-to-apache-cassandra/ [Accessed: 16-May-2014].

9 Planet Casandra Inc., “Bazaarvoice Chooses Casandra over MySQL, HBasa and MongoDB to Power Content Analytics Platform” [Online]. Available: http://planetcassandra.org/blog/post/bazzarvoice-chooses-cassandra-over-mysql-hbase-and-mongodb-to-power-content-analytics-platform/ [Accessed: 16-May-2014].

10 K.Chodorov, “Scaling MongoDB”, O'Reilly Media New York, 2011.

11 J. Pokorny, “NoSQL databases: a step to database scalability in web environment”, Charles University, Praha, 2013.

12 C. Hadjigeorgiou, “RDBMS vs NoSQL: Performance and Scaling Comparison”, The University of Edinburgh, August 2013.

13 M. Fotache, D. Cogean, “NoSQL and SQL Databases for Mobile Applications. Case Study: MongoDB versus PostgreSQL”, University of Iasi, Romania, February 2013.

Information on authors:

Mario Novoselec

e-mail: [email protected]

Faculty of Organization and Informatics

Mario Novoselec is a third year full time undergraduate student at Faculty of Organization and Informatics, University of Zagreb. He is one of the initial members of FOI MT Lab. His main interests are focused towards developing Web applications with emphasis on user experience and modern design. He has also been involved in various non-commercial projects.

Denis Pavlović

e-mail: [email protected]

Faculty of Organization and Informatics

Denis Pavlović is a third year full time undergraduate student at Faculty of Organization and Informatics, University of Zagreb. He is also one of the initial members of FOI MT Lab. He is interested in modern web application design and development. He is involved in various non-commecial projects.

Milan Pavlović

e-mail: [email protected]

Faculty of Organization and Informatics

Milan Pavlović is a third year full time undergraduate student at Faculty of Organization and Informatics, University of Zagreb. He is also one of initial member of FOI MT Lab. His main interests are Information Systems engineering and development. He is also interested in Java desktop, mobile and web application development and technology.

Page 24: Case Mobile

94 CASEmobile

Page 25: Case Mobile

CASEmobile 95

SOFTVER ZA MOBILNE UREĐAJE U JAVNOM PRIJEVOZU

Samir Rizvić, Barbara Rudić, Ivan Pogarčić

SAŽETAK:

U ovom radu definirana su glavna područja ključna za funkcioniranje softvera za mobilne uređaje u javnom prijevozu i analizirana je mogućnost porasta uslužne kvalitete u putničkom prijevozu sa stajališta elemenata koji čine inteligentne transportne sustave implementirane u vozila javnog prijevoza. Poseban naglasak stavljen je na određena područja, bitna za realizaciju takvih tehnologija, odnosno usluga. Kao polazna točka istraživanja, uz internet koji služi kao osnova za funkcioniranje i spajanje softvera, korišteni su uređaji koji su potrebni za realizaciju praćeni detaljnim opisom aplikacije koja može služiti u tu svrhu. Upravo ta aplikacija predložena je kao bitan čimbenik, te je prezentiran način na koji svi ti gore navedeni elementi mogu funkcionirati zajedno. Ostala područja koja su također obrađena su: zadovoljstvo putnika, veća kvaliteta usluge, implementiranje inteligentnih sustava u javni prijevoz i prezentiranje istih korisnicima javnog prijevoza, usklađivanje funkcija softvera, internet i vozila u javnom prijevozu putnika na način na koji će se zadovoljiti potrebe putnika, prijevoznika i okoliša.

SUMMARY:

This paper tries to define main areas, crucial for functioning of mobile phones’ software in the public transport and analyses the possible increase of service quality in the public travelers’ transport from the standpoint of elements comprising the intelligent transportation systems implemented in the public transport vehicles. Special emphasis was given to the specific areas, relevant for the realization of such technologies that is services. Appliances required for realization of such services were used as the starting point of research alongside the Internet that serves as basis for functioning and connecting software, followed by detailed overview of applications which can be used for the same purpose. As an important element a proposition for designing applicative software uniting all the above described areas was proposed, thus presenting the way all these elements can function together. Other areas of interest that were discussed are: travelers’ satisfaction, higher quality of service, implementing the intelligent systems in the public transport and presenting them to the public transport users, harmonizing the operations of software, Internet and vehicles in the public travelers’ transport in ways that will concurrently fulfill needs of travelers, carriers and the environment.

1. UVOD

Javni prijevoz je jedna od primarnih zadaća kod rasterećenja gradskih prometnica. Jednako tako, ako je dobro organiziran, može pridonijeti značajnom smanjenju emisije CO2 plinova u atmosferu. Osim toga, jedan od glavnih ciljeva Europske unije jest održivi promet i snižavanje emisije CO2 i očuvanje okoliša na način da se rasterete gradske prometnice a težište sa cestovnog prometa se prebaci na ostale grane prometa kao što je npr. željeznički promet. Povećanje prometa kroz povećani rast broja vozila na prometnicama rezultira zagađenjem okoliša, atmosfere, postepenim nestankom neobnovljivih izvora energije, zagađenjem pitkih voda, globalnim zatopljenjem. Važniji efekti su štetni učinci na ljude, biljne i životinjske vrste što rezultira istrebljenjem pojedinih vrsta. Međutim, zbog neznanja, neupućenosti ili manjka dobre volje, ljudi i dalje koriste osobna vozila kao svakodnevni način prijevoza. Na taj način u velikoj mjeri štete prirodi ali i samima sebi. Stoga se nameće glavno pitanje: kako ljude navesti da počnu više koristiti neki oblik javnog prijevoza?

Evidentna je činjenica da su ljudi sve više okrenuti uporabi raznih tehnologija do te mjere da se danas često govori i o ovisnosti. Broj pametnih telefona, tableta i prijenosnih računala uvelike je porastao, a njihova uporaba se vrlo često kreće u granicama nekontroliranog konzumerizma. Međutim, koriste li se za zabavu, posao ili kao oblik komunikacije oni su postali neizostavnim dijelom ljudske svakodnevice. Svaki od takvih uređaja za svoje potpuno iskorištavanje i namjenu zahtijeva pristup internetu uz presumpciju potrebne telekomunikacijske infrastrukture. Danas je već veliki broj operatera koji pružaju takve usluge, a neki gradovi imaju pokrivenost besplatnim bežičnim internetom. Također, velika većina korisnika koristi takve uređaje uz stalnu konekciju na Internet. U takvim okolnostima prostor za nova idejna rješenja, koje se mogu implementirati u takve uređaje, je velik.

Populacija koja koristi takve uređaje su uglavnom osobe mlađe i srednje životne dobi, tj. velika većina onih koji bi mogli postati potencijalni korisnici javnog prijevoza, a koji to trenutno nisu. Razvoj kvalitetnog informacijskog sustava u javnom gradskom prijevozu čini se logičnim potezom, a njegova implementacija bi trebala privući,

Page 26: Case Mobile

96 CASEmobile

ali i zadovoljiti, upravo takve korisnike. Mogućnost primjene aplikativnog softvera tijekom prijevoza, obavljanja poslovnih dogovora ili same zabave privukla bi pažnju najveće potencijalne skupine korisnika takvih usluga. Osim toga, informatizacijom javnog prijevoza olakšano je plaćanje usluga što je također važno svojstvo. Ekološki momenti poput smanjenja buke i posljedično smanjenja stresa izazvanog kretanjem velikog broja vozila su korisne posljedice smanjenja uporabe osobnih vozila. Dakle, kvalitetnom informatizacijom sustava javnog gradskog prijevoza otvara se mogućnost zamijene osobnih vozila javnim prijevozom na svakodnevnoj bazi. Uz navedena svojstva evidentni su i prinosi zajednici i okolišu ali i na osobnom nivou kroz smanjenje osobnih troškova.

Rad je koncentriran na prijedlog izrade softvera potrebnog za integriranu uporabu informacija i podataka u urbanoj sredini na primjeru Grada Rijeke.

2. POTREBA ZA JAVNIM GRADSKIM PRIJEVOZOM

Jedan od najvećih problema suvremenih gradova, posebno velikih gradova, je promet. Od uspješnosti rješavanja toga problema ne zavisi samo cirkuliranje ljudi i roba, nego i ukupna kvaliteta života u gradu. Većina suvremenih gradova kronično je opterećena zastojima u uličnom prometu, bukom, onečišćenim zrakom, nedostatkom mjesta za parkiranje i konfliktom pješaka i motornih vozila. S druge strane, javni gradski prijevoznici svakodnevno se susreću sa stalnim padom broja korisnika svojih usluga.

Razlog za takvo stanje je osobni automobil, ne zbog toga što je on osnovni uzročnik problema, već stoga što se njime, u neprihvatljivo velikoj mjeri, pokušava riješiti prometna potražnja. Porast životnog standarda, težnja za sve većom pokretljivošću, udobnost i slično dovode do sve veće upotrebe osobnog automobila. Automobil, kao sredstvo koje je svojim prisustvom najviše pridonijelo prometnoj problematici današnjih gradova, odavno je postao element prestiža. Njegova atraktivnost, bez obzira na prateće probleme, neprekidno raste. Iako postaje u napućenim gradovima relativno sporiji, sve je udobniji, sigurniji, suvremeniji, intenzivnije se troši i češće kupuje.

Gradovi u kojima je, slijedom različitih okolnosti upotreba osobnih vozila reducirana, a javni prijevoz podignut na višu razinu kvalitete, imaju bitno manje problema u gradskom prometu uz znatno višu ukupnu kvalitetu života. Jedini razuman način za usklađivanje individualnih želja i kolektivne volje, koncepti koji su u osnovi kontradiktorni, jest osiguranje usluge javnog prijevoza najviše moguće kvalitete tako da se sugerira velikom broj stanovnika da odustanu od korištenja osobnog vozila i isprobaju mogućnosti koje im nudi javni prijevoz.

Bitno svojstvo javnog prijevoza je sadržano u činjenici da prijevoznici stavljaju na javnu upotrebu prijevozne kapacitete svim potencijalnim korisnicima prometnih usluga. Obavljanje prijevoza je registrirana trajna djelatnost/usluga koju prijevoznik obavlja, uz adekvatnu naknadu, u obliku stalnog zanimanja. Tipičan primjer takvog prijevoza je upravo javni gradski prijevoz putnika (JGPP) koji djeluje u složenom gradskom prostoru i čiji je zadatak da poveže udaljenije prostore i razne sadržaje te tako ostvari njihovo funkcionalno jedinstvo. Porastom broja stanovnika grad prostorno raste i umnožavaju se njegove funkcije pa se samim tim

komplicira zadaća JGPP. Danas se život u gradovima ne može niti zamisliti bez sustava JGPP.

Javni gradski prijevoz putnika je organizirani oblik prevoženju velikog broja stanovnika/putnika unutar gradskog teritorija po ustaljenim trasama i redovima vožnje, a njegova je opća karakteristika da ga pod određenim propisanim uvjetima može koristiti svaki građanin. Prigradski prijevoz putnika, koji povezuje prigradska naselja u gravitacijskom području grada sa užim gradskim područjem, ima istu funkciju kao i javni gradski prijevoz na užem gradskom području. U mnogim slučajevima te dvije vrste prijevoza se međusobno nadopunjuju i predstavljaju jedinstveni sustav prijevoza putnika koji služi prvenstveno dnevnim migrantima da dođu do svoga cilja: posao, škola, rekreacija i dr.(Trbušić, 2006., 2.)

Za normalan život grada javni gradski putnički prijevoz je neophodan kao i opskrba električnom energijom, vodom i slično. Između razvoja gradova i JGPP oduvijek je postojala interakcijska povezanost. Zbog značaja za život grada, javni gradski putnički prijevoz je u svim gradovima u svijetu pod većom ili manjom kompetencijom gradske ili državne vlasti.

Orijentacija na putnika ili korisnika usluga, briga o njegovom zadovoljstvu je osnovni problem u JGPP. Cilj svake tvrtke je postizanje uspjeha u poslovanju. Uspjeh koji se iskazuje u značajem udjela na tržištu, u prepoznatljivom i prihvaćenom proizvodu/usluzi, dokazanoj kvaliteti proizvoda/usluge i sustava organizacije i, naravno, u imidžu firme koji iz svega toga proizlazi. Kvaliteta kao subjektivna kategorija podložna je različitim shvaćanjima i kriterijima. Ovisna je o sredini u kojoj netko živi, navikama i mijenja se tijekom vremena. Ono što je kvalitetno za jednu osobu nije za drugu, a osim toga, ono što zadovoljava putnika u pogledu kvalitete danas, sutra već može biti potpuno neprihvatljivo. Kvaliteta nije stanje kojeg ljudi žele stići, već staza koja vodi prema konstantnom unaprjeđenju usluge. Smisao kvalitete jest povećati zadovoljstvo korisnika tako da se zadrži njihova privrženost i učini ih se stalnim korisnicima usluga. Za putnika je kvaliteta usluge sve. Dosadašnji pristupi tom pitanju, koji ističu samo pojedine aspekte kvalitete putničke usluge kao što su: točnost, sigurnost, frekvencija i neke druge kriterije, previdjeli su to osnovno očekivanje korisnika. Na području JGPP, kao i na bilo kojem drugom području, kvaliteta mora biti zastupljena u svim dimenzijama usluge koja se nudi.

U prijevozu putnika kvaliteta počinje sa sigurnošću i pouzdanošću-odgovornošću, nastavlja se s nuđenjem usluge u skladu s očekivanjima korisnika i kompletna je jedino ako se usluga poboljša do nivoa osobnog kontakta između osoblja i korisnika/putnika odnosno partnerstva. Ovi različiti aspekti kvalitete ne natječu se međusobno, već zajedno doprinose kvaliteti kako ju doživljavaju putnici. Pristup poboljšanju kvalitete ne može se uvesti bez da se zna kakva su očekivanja korisnika/putnika na tom području. Ne utopijske predstave o kvaliteti, o čemu možda maštaju izvan specifičnog konteksta, niti suprotnost kvaliteti, na koju korisnici/putnici objektivno mogu naići na svom slijedećem putovanju, već usluga koju putnik smatra legitimnom i normalnom. Izraz ove očekivane kvalitete znači da svi akteri moraju vidjeti uslugu očima korisnika.

Željena kvaliteta predstavlja ambicije lokalne uprave i prijevoznika na području usluge, dozvoljavajući korisnicima očekivanja i, istovremeno, strategijske izbore učesnika. Željena kvaliteta se izražava kao

Page 27: Case Mobile

CASEmobile 97

očekivani rezultat za korisnika usluge. To je obećanje dano sa strane prijevoznika sa namjerom da se usluga osigura. Postignuta kvaliteta je rezultat poteza koje su poduzeli sudjelujući partneri (prijevoznici, gradska uprava i dr..). Razlika između opažene i postignute kvalitete omogućava da se ocijeni zadovoljstvo korisnika, što je najvažniji pokazatelj uspješnosti aktivnosti na području poboljšanja usluge.

Osnovna komponenta djelovanja je, dakle, detaljna definicija kvalitete koju očekuje putnik i izraženost iste u obliku rezultata za klijente. Očekivana kvaliteta omogućava razvoj metoda i partnerstva za poboljšanje kvalitete kao i ocjenu uspješnosti sustava.

Korist ovakvog pristupa je ta da obuhvaća sve razine odgovornosti i izvedbe usluge. Na primjer, osoblje na određenoj liniji, na nekoj stanici ili smjeni, ili u inspekcijskom timu, formirati će i koristiti istu metodu na toj razini prijevoza, osiguravajući tako potpunu dosljednost.

Prihvaćeni pokazatelj kvalitete i uspješnosti poduzeća je zadovoljstvo korisnika/putnika. Zadovoljan putnik je lojalan putnik i prijevoznik mora učiniti sve da svoje potencijalne korisnike usluge učini stvarnim korisnicima, a svoje trenutne korisnike stalnim korisnicima. Zadovoljan putnik je besplatna reklama prijevoznika i manje je osjetljiv na pojavu poremećaja u prijevozu. Zadovoljan korisnik govori o svome zadovoljstvu nekolicini, dok će nezadovoljan korisnik o svome nezadovoljstvu govoriti puno većem broju ljudi.

Pri ocjenjivanju zadovoljstva putnika treba stalno voditi računa o nekoliko parametara:

zadovoljstvo je dinamičan proces, koji se stalno mijenja, s obzirom na stupanj zadovoljenja zahtijeva, na promjene u očekivanjima, na promjene u subjektivnom i objektivnom okruženju putnika

ne postoji univerzalno, opće zadovoljstvo putnika, nego je to množina pojedinačnih zadovoljstava koje tek svojim ukupnim djelovanjem daju zadovoljstvo putnika kao pojedinca. Zadovoljstvo putnika (kao grupe) je prosjek pojedinačnih očekivanja i emocija

zadovoljstvo je relativan pojam. Lojalnost korisnika ne može se zadržati čak ni zadovoljstvom koje osjeća. Napuštati znaju i zadovoljni korisnici.

3. KRATKI OSVRT

Inteligentni transportni sustav (ITS) je upravljačka i informatičko-komunikacijska nadogradnja (ili nadgradnja) klasičnog prometnog i transportnog sustava, tako što se postiže bitno veća propusnost, sigurnost, zaštićenost i ekološka prihvatljivost u odnosu na rješenja bez ITS aplikacija. (Bošnjak, 2008., 161.) To znači da se kroz stvarno vremensko prikupljanje i obradu podataka te umreženu distribuciju informacija postiže znatno smanjenje zagušenja, čekanja, prometnih nesreća, neučinkovitosti prijevoza, ekoloških onečišćenja itd.

Atribut „inteligentni” općenito označava sposobnost adaptivnog djelovanja u promjenjivim uvjetima i situacijama, pri čemu je potrebno prikupiti dovoljno podataka i obraditi ih u stvarnom vremenu. Koncept inteligentnih informacijskih sustava (IIS) blizak je informatičarima kao i različite napredne tehnike koje su zajedničke IIS-u i ITS-u. Koncepti i tehnike umjetne inteligencije (AI tj. Artificial Intelligence) - prepoznavanje oblika, strojno učenje, inteligentno izračunavanje itd.,

koriste se u dizajniranju, razvoju i implementaciji različitih ITS aplikacija.

Stanovnik europskog grada izgubi prosječno jednu godinu života u dodatnim čekanjima zbog prometnih zagušenja i neposjedovanja ažurnih informacija o odvijanju prometa. Problemi gradova i davatelja usluga u javnom prijevozu takvi su da je klasični pristup nužno zamijeniti pristupom inteligentnih transportnih sustava pri rješavanju pitanja kvalitete usluge, sigurnosti i onečišćenja okoliša. ITS rješenja uključuju redizajn prometne infrastrukture s novim prometnim rješenjima organizacije i vođenja tokova, inteligentnim navođenjem na rute s manjim opterećenjem, informiranjem o slobodnim parkirnim mjestima, daljinskim praćenjem tereta i vozila, telematskom naplatom cestarine, upravljanjem incidentnim situacijama u prometu itd.

Možemo reći da ITS predstavlja: napredni koncept rješavanja prometnih problema, znanstvenu disciplinu, skup tehnologija i novi tehnološki pokret. To dokazuju programi i projekti ITS-a u svim razvijenim zemljama, uspostavljanje ITS-a kao akademske discipline i studijskog programa na sveučilištima, te uspješno djelovanje niza nacionalnih i međunarodnih ITS udruga (ITS Croatia osnovana 12. listopada 2005). Za razliku od izoliranih tehničkih rješenja (zeleni val, promjenjivi znakovi, telematički uređaji u vozilima) koncept ITS-a predstavlja „sustav sustava”, kako je to objašnjeno u naprednim priručnicima (Highway Capacity Manual, Intelligent Transport Primer itd.).

Uvjerljivi razlozi za ITS slijede iz poraznih podataka o sigurnosti i eksternim troškovima odvijanja prometa. Prema podacima organizacije „WHO“, preko 1,2 milijuna ljudi svake godine smrtno strada u prometu, a 50 milijuna biva ozlijeđeno. Ukupni izravni i eksterni troškovi prometnih nesreća iznose 3 do 4 % bruto BDP-a pojedinih zemalja.

4. PODRUČJA ISKORISTIVOSTI INTELIGENTNIH TRANSPORTNIH SUSTAVA

Međunarodna organizacija za normizaciju „ISO“ definirala je 11 domena ITS-a:

1. informiranje putnika (Traveler Information)

2. upravljanje prometom i operacijama (Traffic Management and Operations)

3. vozila (Vehicles)

4. prijevoz tereta (Freight Transport)

5. javni prijevoz (Public Transport)

6. žurne služne (Emergency)

7. elektronička plaćanja vezana uz transport (Transport Related Electronic Payment)

8. sigurnost osoba u cestovnom prijevozu (Road Transport Related Personal Safety)

9. nadzor vremenskih uvjeta i okoliša (Weather and Environmental Monitoring)

10. upravljanje odzivom na velike nesreće (Disaster Response Management and Coordination)

11. nacionalna sigurnost (National Security)

U skladu s temom rada bitno je usredotočiti se na određena područja usluga. U području usluga informiranja putnika (traveller information) obuhvaćene su statičke i dinamičke informacije o prometnoj mreži, usluge predputnog i putnog informiranja, te podrška službama koje obavljaju prikupljanje, pohranjivanje i

Page 28: Case Mobile

98 CASEmobile

upravljanje informacijama za planiranje transportnih aktivnosti.

Usluga predputnog informiranja (pre-trip information) omogućuje korisnicima da iz doma, odnosno sa svog radnog mjesta ili druge javne lokacije dođu do korisnih informacija o raspoloživim opcijama, vremenu ili cijenama putovanja. Naglasak je na multimodalnim i intermodalnim informacijama.

Putno informiranje (on-trip information) uključuje stvarnovremenske informacije o putovanju, procjenu vremena putovanja ovisno o postojećim uvjetima, raspoloživosti parkirnih mjesta, prometnim nezgodama itd.

Informacije se pružaju putem terminala na autobusnim i željezničkim postajama, trgovima, tranzitnim točkama, ekranima u vozilu ili prenosivim osobnim terminalima.

Usluge rutnog vodiča i navigacije mogu se odnositi na predputno i putno informiranje o optimalnoj ruti ili putanji do naznačenog odredišta. Izbor najbolje rute temelji se na informacijama o prometnoj mreži i javnom prijevozu te uključuje multimodalne opcije s rješenjima kao što su Park & Ride i druga.

Primjeri tih usluga su:

dinamički rutni vodič u vozilu (Dynamic In-vehicle Route Guidance)

integrirani multimodalni putni vodič pješački ili biciklistički rutni vodič.

Podrška planiranju putovanja (Trip Planning Support) pruža podatke o prometnim tokovima i transportnoj potražnji u svrhu transportnog planiranja. To su aktualni i povijesni podaci iz prometnih upravljačkih i informacijskih sustava, te podaci od vozila u pokretu (Probe Vehicles).

U ITS području pod nazivom vozila (Vehicles) nalazi se više usluga kojima se poboljšava operativna sigurnost vozila:

poboljšanje vidljivosti (Vision Enhancement) asistencija vozaču i automatske radnje vozila sprečavanje sudara sigurnosna upozorenja itd.

U području javnog prijevoza (Public Transport) definirano je više usluga koje omogućuju redovite i učinkovite radnje javnog prijevoza uz pružanje ažurnih informacija korisnicima.

Primjeri tih usluga su:

napredni sustav javnog prijevoza praćenje voznog parka napredni sustavi dispečinga zajednički transport (Shared Transport)

U području elektronička plaćanja vezana uz transport nalaze se usluge:

elektronička naplata javnog prijevoza elektronička naplata cestarine elektronička naplata parkiranja daljinska plaćanja itd.

Integracija različitih sustava plaćanja i institucija uključenih u sustav obuhvaća tehničko-tehnološka i međuorganizacijska rješenja. (Bošnjak, 2006., 25.)

Sprečavanje zagušenja i adaptivno vođenje toka vozila predstavlja jedan od najznačajnijih područja primjene ITS aplikacija. Za efektivno i učinkovito vođenje prometnog toka potrebno je dublje poznavanje relevantnih veličina, te načina prikupljanja i obrade stvarnovremenskih podataka kako bi se različitim oblicima distribucije informacija djelovalo na tok.

Produbljeno poznavanje teorije prometnog toka i temeljnih načela vođenja složenih sustava ključno je za razvoj brojnih ITS aplikacija, kako na autocestama, tako i na drugim dijelovima prometnog sustava. Opetovano zagušenje nastaje u očekivanim jutarnjim ili popodnevnim vršnim satima, odnosno u predvidivim intervalima vikendom. Ključna upravljačka akcija (unaprijedno vođenje) jest informiranje i savjetovanje putnika i vozača neposredno prije nastajanja vršnih opterećenja, odnosno preusmjeravanje prometa na druge, manje opterećene prometnice. (Bošnjak, 2009., 9.)

U osnovne funkcije računalno podržanog sustava nadzora i upravljanja poduzeća pripadaju:

utvrđivanje lokacije vozila usporedba zadanog i stvarnog stanja u prometu

radi nadzora voznog reda automatska razmjena informacija putem

podatkovne radio komunikacije upravljanje govornom komunikacijom kontinuirano informiranje dispečera o aktualnom

stanju radnog procesa prikaz radne situacije u grafičkom i tabličnom obliku usporedba zadanog/stvarnog stanja radi nadzora

tura (usporedba zadanog/stvarnog učinka) alati za pomoć dispečeru kod organizacijskih

dispozicijskih mjera (upravljanje smetnjama) nadzor posebnih događaja protokoliranje svih važnih informacija i zahvata osiguranje alata za dijagnozu (npr. analiza voznih

podataka) nadzor veza i osiguranje veza informacija za putnike u stvarnom vremenu (DFI) utjecaj na svjetlosnu signalizaciju

Korištenjem mogućnosti ITS sustava te integracijom s cjelovitim prometnim rješenjima ITS-a na području urbane sredine prometno poduzeće ostvaruje sljedeće ciljeve:

Povećanje atraktivnosti javnog prometa kao i prihvaćanja javnog prometa od strane putnika na osnovi obilježja kakvoće, kao što su pouzdanost, raspoloživost i jednostavno rukovanje putem:

postizanja maksimalne točnosti i redovitosti poboljšanja sigurnosti veza kod presjedanja skraćivanja vremena prijevoza mogućnošću

utjecaja na svjetlosnu signalizaciju bolja informiranost putnika na stajalištima putem

stvarnih podataka, kao i davanje informacija u vizualnom i akustičnom obliku.

Pojednostavljenje radnih procesa i povećanje efikasnosti i ekonomičnosti za prijevoznika može se postići:

optimizacijom korištenja vozila i osoblja optimizacijom vremena prometovanja vozila

(vrijeme obrta) ranim prepoznavanjem radnih i tehničkih

nepravilnosti i smetnji učinkovitim radom osoblja u centrali povećanom fleksibilnošću na temelju mogućnosti

da se vozilo koristi prema potrebi.

Primjena ICT-a, telematike i ITS tehnologije omogućuje da prijevoz putnika funkcionira bolje, efikasnije i omogućuje povećanje alternativnih tipova usluge. U konačnici, organizacija omogućuje ekonomski efikasniji sustav. Što se tiče putnika, ITS omogućuje veću atraktivnost sustava prijevoza putnika koja pomaže da se putnici lakše odluče na putovanje javnim gradskim prijevozom.

Page 29: Case Mobile

CASEmobile 99

5. PARK & RIDE SUSTAV U FUNKCIJI JAVNOG GRADSKOG PRIJEVOZA

Cilj Park & Ride sustava je smanjenje prometnih gužvi, odnosno broja osobnih vozila na prometnicama i parkiralištima u samom središtu grada. Suština je sustava da se korisniku (vozaču i/ili putniku) ponudi mogućnost jednostavnijeg odlaska u gradsko središte korištenjem sredstva javnog prijevoza umjesto individualnog automobila. (Generalni urbanistički plan Grada Rijeke, 2001.) U svijetu i u Europi primjenjuju se najčešće dvije osnovne varijante Park & Ride sustava: Određeni Park & Ride terminali sa pratećim

sadržajima i parkiranjem pod naplatom, koja uključuje cijenu karte javnog gradskog prijevoza; Otvorene ili zatvorene parkirališne površine,

uređene uz terminale javnog gradskog prijevoza bez naplate parkiranja. Budući da sam Park & Ride sustav služi kao nadopuna, odnosno poboljšanje javnog gradskog prijevoza putnika, može biti olakšan korištenjem i kombinacijom istog aplikativnog softvera, kao što je već i integriran na parkirališnim prostorima. Očito je da se pravilnim planiranjem gradske prometnice daju rasteretiti i privući novi korisnici. Također, dodavanje dodatnih funkcija unutar aplikativnog softvera ne bi trebao predstavljati veći problem pa se umjesto sustava naplate za parkirališni prostor, odnosno za javni prijevoz sve može povezati unutar jedne aplikacije čime bi se svime olakšalo korištenje i povećalo zadovoljstvo samim korištenjem aplikacije. Isto tako, dobio bi se uvid o slobodnim parkirališnim mjestima na pojedinim terminalima kako ne bi dolazilo do gužve i postojala bi mogućnost za rezervacijom parkirnog mjesta (izvedivo pomoću stupića, posebnog ključa, asistencijom zaposlenika, itd.) na kraći period, odnosno pretplatom.

Slika 1. Primjer Park & Ride sustava

(Izvor: thexrt.blogspot.com, 24.4.2014.)

6. SPECIJALIZIRANOST APLIKATIVNOG SOFTVERA

Neka je za potrebe ovog rada aplikativni softver definiran kao skup programa koji imaju specijaliziranu namjenu, kao što je obrada teksta, slike, zvuka, dizajn i upravljanje bazama podataka, izrada web stranica itd. (Lemeš, 2006., 1)

Specijaliziranost aplikativnog softvera se ogleda u njegovoj namjeni određenoj prema vrsti korisnika. Jednako tako svaki specijalizirani softver treba biti prilagođen širem spektru korisnika. Zbog toga se inzistira na njegovoj jednostavnosti pri uporabi. Obično se aplikativni softver može kupiti na tržištu kao gotov proizvod ili se može naručiti njegova izrada ili ga u krajnjem slučaju korisnik može izraditi sam. Tržište mobilnih aplikacija je brzo rastuće te je izrada aplikacija za mobilne platforme logičan izbor tvrtkama koje žele ponuditi i prilagoditi svoje servise za mobilne platforme. Prije svega, ovo proizlazi iz toga što današnje mobilne platforme nude vrhunski user-experience i lokacijski neovisan pristup do informacija putem brzih 3G/4G mreža. Nije zanemariva niti marketinška vrijednost koju donose mobilne aplikacije za tvrtke koje odluče nuditi svoje servise putem mobilnih platformi. Distribucija mobilnih aplikacija obično je centralizirana te ih korisnici preuzimaju ili kupuju putem internetskih trgovina.(slika 2)

Slika 2. Apple-ov „Appstore“ - virtualna trgovina aplikacijama (Izvor: www.apple.com)

Page 30: Case Mobile

100 CASEmobile

7. UPOTREBA APLIKATIVNOG SOFTVERA

Najvažnije pitanje mobilne strategije jedne tvrtke jest da li uopće napraviti posebnu aplikaciju za mobilne uređaje. Neke tvrtke uistinu ne trebaju aplikaciju za mobilne uređaje ali zato trebaju svoje stranice učiniti lako čitljivima na malim ekranima mobilnih uređaja. No, ako web stranice imaju dobru posječenost mobilnih korisnika, javlja se drugo pitanje: Treba li izdati aplikaciju za mobilne uređaje?

Trenutno, nije potrebno previše promišljati već izdati aplikaciju za mobilne platforme. Istraživanje koje je proveo guru upotrebljivosti Jakob Nielsen jasno pokazuje da se korisnici puno lakše i brže snalaze aplikacijama nego s mobilnim verzijama web stranica. Desktop/pune web stranice koje se prikazuju na mobilnim uređajima ipak zadaju najviše glavobolje korisnicima mobilnih uređaja, odnosno pametnih telefona. (Vukovac, 2012., 89)

Aplikacije za mobilne uređaje su puno jednostavnije za korištenje od mobilnih stranica zato jer je na mobilnim stranicama moguće postići tek djelomično zadovoljenje potreba i u većini slučajeva radi se u samom procesu dizajna web stranice. Aplikacija s druge strane može ciljati na specifična ograničenja i mogućnosti svakog pojedinog uređaja, naglašava prednosti i umanjuje ograničenja svakog uređaja. Što je mobilni uređaj slabiji to je potrebno uložiti više u optimizaciju same aplikacije. Mogućnost mikro plaćanja ili plaćanja unutar aplikacije (In App Purchase) dodatna je mogućnost na koju se nikako ne smije zaboraviti.

Troškovi razvoja mobilne aplikacije vremenom će se povećavati, prvenstveno zato jer će biti više platformi za razvoj, više specifičnih uređaja za koje će se trebati aplikacija razvijati. Kao minimum, aplikacija će morati podržavati iOS, Android i Windows Phone. Nadalje, mnoge od tih platformi vjerojatno će se podijeliti na više podplatformi koje zahtijevaju različite aplikacije za pristojnu korisničku upotrebljivost, ovdje prvenstveno mislimo na cijeli ekosustav Androida. Nije ovdje imun niti Apple-ov iOS. Sam iOS podijelio se na ekosustav

iPhone-a/iPod-a i iPad-a. Iako službeno je to još uvijek jedan, isti iOS, za aplikaciju potrebno je dizajnirati posebno sučelje za iPhone/iPod i iPad (ne uzimajući u obzir razlučivost ekrana unutar svakog od ova dva ekosustava). Dakle, realno je za očekivati daljinu diverzifikaciju mobilnih uređaja (pametnih telefona i tableta) u budućnosti.

S druge strane, izrada web stranice prilagođene web preglednicima mobilnih uređaja je puno jednostavnija i jeftinija, kako danas, tako i u budućnosti. Pripremiti web stranicu potrebno je tek za tri formata, za pametne telefone, "male" tablete sa (oko) sedam inčnim ekranima kao što su Galaxy Tab 7, 7.7 ili Kindle Fire, te za velike tablete kao što su iPad ili Samsungovu liniju velikih tableta. Dok su razlike dizajna sučelja za tablete malena, priprema dizajna za pametne telefone koji su ispod 5 inča zahtjeva ipak malo više pripreme i preinaka.(slika 3)

Pametni telefoni i tablet uređaji u posljednje vrijeme u velikom su zamahu, te doslovno preplavljuju tržište mobilnih telekomunikacija i uređaja. Njihova popularnost i broj korisnika raste iz dana u dan, te su sasvim opravdane prognoze kako će se u skoroj budućnosti otvoriti više web stranica za mobilne uređaje nego za računala. Paralelno s tim još više će porasti potražnja za specijaliziranim mobilnim aplikacijama. Već danas mobilne aplikacije predstavljaju čimbenik koji je najviše pridonio naglom porastu tržišta pametnih telefona i glavni su nositelj mobilne revolucije.

Sve veći broj korisnika ima pametne mobilne telefone, koji zahvaljujući velikom zaslonu i brzom procesoru mogu biti računala u malom. Za njih se razvijaju posebne aplikacije, prilagođene karakteristikama i gabaritima tih uređaja, koje mogu biti vrlo atraktivne i korisne. Tržište takvih aplikacija je u strelovitom porastu, a marketinške i ine koristi od izdavanja vlastite aplikacije za telefon su višestruke.

Izrada web stranica i aplikacija za mobilne uređaje nešto je kompliciranija od izrade klasičnih verzija za računala. Danas na tržištu postoji veliki broj različitih

Slika 3. Usporedba mobilne i obične web stranice učitane na mobilnom uređaju (Izvor: www.bluefountainmedia.com)

Page 31: Case Mobile

CASEmobile 101

pametnih telefona koji koriste različite operativne sustave i preglednike za surfanje internetom, pa sadržaj treba prilagoditi posebno za svaki od njih. Sljedeća važna karakteristika je što su mobilni uređaji daleko manji od monitora računala, pa sadržaj treba optimalno smjestiti na manje ekrane, a osim toga i same veličine ekrana variraju od uređaja do uređaja.

8. PRIJEDLOG IZRADE APLIKATIVNOG SOFTVERA ZA MOBILNE UREĐAJE U JAVNOM PRIJEVOZU – PRIMJER GRADA RIJEKE

Izrada aplikacije za javni prijevoz bila bi od velike koristi za sve sudionike u prometu, izravne i neizravne na način da bi privukla korisnike i ujedno im olakšala korištenje usluge. Autoprijevoznik bi na taj način dobio veći broj korisnika i znatno veći broj izravnih povratnih informacija čime bi mogao poboljšati svoju uslugu. Drugi je razlog smanjenje broja osobnih vozila na cestama i posljedično smanjuje buka i zagađenje okoliša.

Činjenica je da velik broj ljudi koristi pametne telefone i tablete a u skladu s tim i razne društvene mreže na kojima se takva usluga može promovirati, kao i dućani za aplikacije na samim uređajima koje koriste. Jedan od načina je i u vidu besplatne vožnje samom registracijom unutar aplikacije ali i kupnjom standardnih pokaznih kupona na kojima bi bio kod koji bi korisnik mogao jednokratno unijeti u aplikaciju i iskoristiti ga za besplatnu vožnju.

Također, nakon kupnje pokaza unutar aplikacije, isti bi se mogao koristiti i bez da je uređaj stalno spojen na internet čime bi sama usluga bila mnogo funkcionalnija i pogodnija za korištenje svim korisnicima.

Slika 4. Početno sučelje aplikativnog softvera (Izvor: Izradio autor)

Početni zaslon aplikacije sadržavao bi osnovne funkcije koje bi bile dostupne u svakom trenutku prilikom upotrebe aplikacije unutar bilo kojeg prozora. To su osnovne funkcije i služe kao glavne kategorije unutar

kojih se nalaze opcije koje možemo odabrati. Te kategorije su:

Pokazni kupon ( popoularno. pokaz) Odabir autobusne linije Vozni red Postavke

Slika 5. Izgled sučelja funkcija dnevnog i mjesečnog pokaza u aplikativnom softveru (Izvor: Izradio autor)

Page 32: Case Mobile

102 CASEmobile

Glavna funkcija bi omogućavala korištenje pokaznog kupona na način da bi korisnik kupnjom istog dobio sve podatke izravno na ekran, bez potrebe za korištenjem standardnih načina pokaza a kontrolor bi mogao provjeriti valjanost skeniranjem qr koda koji bi zauzimao najviše prostora na ekranu kako bi u svakom trenutku bio lako dostupan i jednostavan za učitavanje. Kategorije unutar funkcije pokaznog kupona su sljedeće:

Dnevni pokaz Mjesečni pokaz Ostalo (poludnevni, obiteljski, godišnji,

umirovljenički i ostale vrste pokaza)

Svi podaci vezani uz istek pokaza bili bi vidljivi u obliku brojčanog odbrojavanja, a pokaz bi se jednostavno mogao obnoviti pritiskom na funkciju „obnovi“ koja bi bila povezana s korisničkim računom u kojem bi već unaprijed bio definiran način plaćanja pa ne bi bilo potrebe za ponovnim unosom informacija vezanih uz način i vrstu plaćanja. Mjesečni i ostale vrste pokaza razlikovali bi se po tome što bi koristili i sliku, te osobne podatke za jednostavniju kontrolu. Unutar funkcije „postavke sučelja“ bilo bi omogućeno izabrati koji način pokaza će se pojaviti kao primarni kako korisnik koji učestalo koristi aplikaciju ne bi morao iznova odabirati željenu funkciju koju najčešće koristi. Unutar funkcije „obavijesti“ korisnik bi dobivao informacije o skorom isteku pokaza i načinu obnove. Kao i na standardnom fizičkom dnevnom, mjesečnom i ostalim vrstama pokaza pozadina bi služila kao mjesto gdje bi se mogle nalaziti sponzorske reklame u vidu slika ili pokretnih animacija, a u slučaju više sponzorskih reklama bile bi regulirane veličinom i duljinom trajanja prikaza.

Slika 6. Izgled sučelja funkcija odabira linije i relacije u aplikativnom softveru (Izvor: Izradio autor)

Odabir autobusne linije korisniku bi služio kao vodič ili kao mjesto informiranja o određenoj liniji ili relaciji kojom se kreće ili koju namjerava koristiti. Postojala bi dva načina korištenja:

Odabir linije Odabir relacije

Odabir linije služio bi korisnicima koji unaprijed znaju koju autobusnu liniju žele koristiti i na taj način jednostavno mogu odabrati željenu liniju koja će automatskim putem biti predložena ulaskom u autobus.

S druge strane, odabir relacije je opcija koja bi bila od velike koristi korisnicima koji nisu upoznati s kretanjem linija a htjeli bi na jednostavan, brz i siguran način doći do željene lokacije. To bi im bilo omogućeno upisom mjesta polazišta i mjesta odredišta ili automatskim odabirom trenutne lokacije i upisom mjesta odredišta. Nakon što bi odabrali lokacije bila bi im ponuđena najbrža ili najkraća relacija, uključujući kretanje samo jednom linijom ili kombinacijom više linija s presjedanjima.

Page 33: Case Mobile

CASEmobile 103

Slika 7. Izgled sučelja funkcija popisa stanica i odabira rute u aplikativnom softveru (Izvor: Izradio autor)

Nakon što je linija odabrana umjesto ikonice autobusa pojavljuje se ikonica s brojem linije a opcije odabira linije i relacije zamijenjene su opcijama:

Popis stanica Ruta kretanja

Opcija „popis stanica“ sadržavala bi popis svih stanica na odabranoj liniji s mogućnošću slobodnog pregleda stanica ili s mogućnošću odabira trenutne lokacije čime bi se stanice automatski izmjenjivale kretanjem autobusa a sve to bilo bi popraćeno i s praćenjem udaljenosti do sljedeće stanice i prikazom vremena potrebnog za pristizanja autobusa na sljedeću stanicu.

Koristeći rutu kretanja korisnik bi u svakom trenutku mogao pregledati rutu po kojoj se autobus kreće a

odabirom opcije korištenja trenutne lokacije mogao bi u realnom vremenu pratiti kretanje autobusa i pratiti udaljenost do sljedeće stanice, kao i vrijeme potrebno do pristizanja autobusa na sljedeću stanicu. Bio bi omogućen odabir obične, satelitske ili kombinirane karte a postojala bi i mogućnost prikaza važnijih lokacija ili događanja uz rutu kretanja.

Slika 8. Izgled sučelja funkcija odabira gradskih linija i mreže linija u aplikativnom softveru (Izvor: Izradio autor)

Page 34: Case Mobile

104 CASEmobile

Sljedeća funkcija dostupna korisniku je „vozni red“. Vozni red omogućava korisnicima, najčešće prigradskih linija, da u bilo kojem trenutku imaju dostupnu informaciju o vremenu pristizanja autobusa. Funkcije koje sadrži su:

Gradske linije Prigradske linije Mreža linija

Osim standardnog prikaza voznih redova za gradske i prigradske linije postojala bi i mogućnost uvođenja voznog reda i za noćne linije. Mreža linija bila bi prikaz svih linija na području grada, grafički ucrtanih na mapu sa nazivima stajališta i rutom kretanja svih linija označenih različitim bojama radi lakšeg snalaženja na karti. Time bi se postigao pristupačan, jednostavan i pregledan način informiranja korisnika o autobusnim linijama, dijelovima grada koje pojedine linije povezuju i mogućnosti presjedanja.

Slika 9. Izgled sučelja postavki u aplikativnom softveru

(Izvor: Izradio autor)

Opcija postavke služila bi za promjenu svih korisničkih podataka, kao i za promjenu postavki sučelja i komunikaciju s autoprijevoznikom ali i drugim korisnicima putem društvenih mreža. Kategorije unutar postavki su sljedeće:

Postavke korisničkog profila Postavke aplikativnog sučelja Povezivanje računa Bodovi Obavijesti Kontakti

Postavke korisničkog profila gdje bi bilo omogućeno mijenjati osobne podatke, načine plaćanja i izmjenu fotografija. Svaki korisnik bi imao personalizirano sučelje prijavom na bilo kojem uređaju i u svakom

trenutku bi se mogao odjaviti s uređaja kojeg trenutno koristi.

U postavkama sučelja korisnik bi bio u mogućnosti odabrati sam izgled i boju sučelja, boju i veličinu fonta (bitno za osobe s problemima u vidu), uključiti i isključiti zvuk prilikom dodira određenih funkcija, odabrati što će mu biti početni ekran prilikom ulaska u aplikaciju i odabir linije koja će biti primarna.

Budući da velika većina ljudi svakodnevno koristi društvene mreže, bili bi u mogućnosti povezati račune čime bi mogli na jednostavniji način, odnosno automatski unijeti osobne podatke, ali i dijeliti rute, obavijesti i bodove s drugima.

Bodovi su kategorija koja bi u suradnji s autoprijevoznikom i sponzorima omogućila stimulaciju putnika na češće korištenje javnog prijevoza u vidu bodova kojima bi se mogle kupovati karte, razne ulaznice te bi imali mnoge pogodnosti, slično kao u aviokompanijama gdje koriste „nagradne milje“.

Obavijesti su jedna od vrlo bitnih stavki a omogućile bi upozoravanje korisnika o prispijeću autobusa na autobusnu stanicu u određenom vremenskom periodu, trenutku kada je potrebno izaći iz busa (korisno za turiste), mogućnosti osvajanja bodova, događanjima na lokaciji u neposrednoj blizini rute po kojoj se korisnik u autobusu kreće, kašnjenjima, gužvama na cesti, trenutnoj lokaciji autobusa, itd. Također bi korisnici u bilo kojem trenutku mogli kontaktirati autoprijevoznika, iznijeti svoja mišljenja o usluzi, trenutnoj vožnji, vozačima, stanju na cesti, gužvama, kašnjenju i mnogim drugim stavkama za koje smatraju da su bitne ili korisne. Primljene informacije autoprijevoznik može dijeliti sa svojim korisnicima i na taj način bi se poboljšala usluga koju pružaju ali bi se i omogućilo da svi sudjeluju i skupa tu uslugu učine boljom, sigurnijom i udobnijom.

9. ZAKLJUČAK

Javni gradski prijevoz osmišljen je kao način prijevoza koji će rasteretiti gradska središta, povezati različite dijelove grada i pridonijeti sigurnosti u prometu. Na mnogo načina se nastoji poboljšati javni prijevoz, bilo novim prijevoznim sredstvima ili poboljšanjem kvalitete usluge čime se nastoji privući što veći broj ljudi. Isto tako korisnici usluga također traže što pristupačniju uslugu uz visok stupanj informatizacije sustava.

Stanovnik europskog grada izgubi prosječno jednu godinu života u dodatnim čekanjima zbog prometnih zagušenja i neposjedovanja ažurnih informacija o odvijanju prometa. Problemi gradova i davatelja usluga u javnom prijevozu takvi su da je klasični pristup nužno zamijeniti pristupom inteligentnih transportnih sustava pri rješavanju pitanja kvalitete usluge, sigurnosti i onečišćenja okoliša.

Primjene informacijsko komunikacijske tehnologije u sustavu javnoga gradskog prijevoza putnika, mnogostruke su, te postaju ključna u logističkom smislu upravljanja uslugama javnoga gradskog prijevoza putnika.

Danas u Zagrebu postoji naplata karata u vozilima javnog gradskog prijevoza putnika putem mobilnog telefona, što Zagreb stavlja sam vrh razvijenih gradova svijeta u primjeni ICT tehnologije. Pravilnom primjenom bi se trebao smanjiti broj neplaćenih karata, potreba da se ima sitan novac i manipulacija s njime, te

Page 35: Case Mobile

CASEmobile 105

pojednostavljena primjena naplate voznih karata, kako za korisnika tako i za prijevoznika.

Primjena takve tehnologije omogućuje da prijevoz putnika funkcionira bolje, efikasnije i omogućuje povećanje alternativnih tipova usluge. Konačno, organizacija omogućuje ekonomski efikasniji sustav. Što se tiče putnika, takav sustav omogućuje veću atraktivnost sustava prijevoza putnika koja pomaže da se putnici lakše odluče na putovanje javnim gradskim prijevozom.

Izrada kvalitetne aplikacije za javni prijevoz bila bi od velike koristi za sve sudionike u prometu, izravne i neizravne na način da bi privukla korisnike i ujedno im olakšala korištenje usluge, autoprijevoznik bi na taj način dobio veći broj korisnika i znatno veći broj izravnih povratnih informacija čime bi mogao poboljšati svoju uslugu, dok bi svima ostalima bila od koristi budući da se smanjenjem broja osobnih vozila na cestama smanjuje buka i zagađenje okoliša.

Literatura:

1 Downey, D. F. et al, Ion Implantation Technology, Prentice-Hall (New York, 1993), pp. 65-67. [A book reference…]

2 Wasserman, Y, “Integrated Single-Wafer RP Solutions for 0.25-micron Technologies,” IEEE Trans-CPMT-A, Vol.17, No. 3 (1995), pp. 346-351. [A reference to a journal article …]

3 Shu, William K., “PBGA Wire Bonding Development,” Proc 46th

Electronic Components and Technology Conf, Orlando, FL, May. 1996, pp. 219-225. [A reference to a presentation at a Conference…]

4 Institut građevinarstva Hrvatske d.d., Poslovni centar Rijeka: Generalni urbanistički plan Grada Rijeke, prometni dio, knjiga 1, Rijeka, 2001.

5 thexrt.blogspot.com, 24.4.2014

6 www.apple.com

7 www.bluefountainmedia.com

Podaci o autorima:

Samir Rizvić, bacc.ing.traff

e-mail: [email protected],

Barbara Rudić, viši predavač

e-mail: [email protected]

Doc. dr.sc. Pogarčić Ivan

e-mail: [email protected]

Profesor visoke škole na Veleučilištu u Rijeci

Voditelj studija informatike pri Veleučilištu u Rijeci

Veleučilište u Rijeci, Trpimirova 2,

+385 51 32 13 00

e-mail: [email protected]

http:/www.veleri.hr

Page 36: Case Mobile

106 CASEmobile

Page 37: Case Mobile

CASEmobile 107

SUSTAV PREPOZNAVANJA SLIKOVNIH UZORAKA MOBILNIM UREĐAJEM

IMAGE PATTERN RECOGNITION USING MOBILE DEVICES

Alen Huskanović, David Ante Macan, Zoran Antolović, Boris Tomaš, Marko Mijač

SAŽETAK:

Prepoznavanje slikovnih uzoraka se do sada obavljalo isključivo koristeći ili složena i skupa programska rješenja i uređaje (optičke čitače). Mobilni uređaji razvili su se do mjere u kojoj ih je moguće iskoristiti za takve obrade, ali algoritmi i sustavi koji to rade u realnom vremenu su rijetki. Ovaj rad opisuje razvoj algoritma u sklopu PEAS sustava, kojim je omogućeno prepoznavanje uzoraka na listi za odgovore (eng. scorecard) koristeći mobilne uređaje. Pri tome ćemo prikazati teorijske osnove prepoznavanja slikovnih uzoraka, implementaciju algoritma pomoću OpenCV i JavaCV biblioteka te praktična iskustva u takvom pristupu.

ABSTRACT:

Image pattern recognition has been so far carried out almost exclusively using sophisticated and expensive software solutions and devices. Mobile devices have evolved to the extent that they can be used for such purpose, but the algorithms and systems that provide such functionalities in real time are rare. This paper describes the development of an algorithm within PEAS system, which enables the identification of answers in scorecard paper sheet using mobile devices. Thereby we will show the theoretical basis of the image pattern recognition, implementation of the algorithm using the OpenCV library and JavaCV, and the practical experience in such an approach.

1. INTRODUCTION

Today, image processing has found use in many aspects of ICT technologies. But, until recently, this task was mainly reserved for desktop computers, workstations, server computers, due to its high hardware requirements. However hardware and software capabilities of today’s mobile device’ are increasing rapidly, which among other things results in image processing becoming more and more available on those devices as well. Since the mobile devices are compact and highly portable, new possibilities are opening from many aspects, including the image processing one. Such possibilities include computer vision, virtual reality, augmented reality, pattern recognition etc., finding its application in entertainment industry, health, security, government, biometrics, tourism, education...

One of the possibilities for utilizing image processing is its application in overall educational process. This paper shows the attempt to utilize mobile devices and image processing capabilities to improve evaluation process in education, as a part of PEAS (‘Personal Exam Assistant’) project. PEAS tries to automate and speed up the process of exam evaluation in educational institutions, thereby realizing benefits for both teacher and students. A significant part of PEAS system is a mobile application whose role is to take a picture of scorecard sheet, identify the marked answers and send them to server system for evaluation.

The central issue in this mobile part of PEAS system was the identification of marked answers on scorecard sheet in native mobile application. In order to achieve this functionality, we aimed to develop algorithm for distinctive marked rectangle detection from the mixed grid of marked and unmarked rectangles.

Although used for the reason stated above, this algorithm can easily be modified for recognition of various different image pattern types.

The algorithm itself is fragmented into several smaller partial problems which we managed to surpass successfully. Such partial problems are: contour and edge detection, corner calculation, perspective correction, shadow removal, answer identification, answer marking on the picture itself...

As previously mentioned, today’s mobile devices have the capacity for such processing tasks, as well as the cameras of enough quality level, so that the images could be easily fetched from the devices camera and instantly prepared for further processing.

In order to ease the implementation of algorithm we identified several image processing frameworks that could be used, such as: openCV, imageJ, FastCV etc. For this algorithm, we used some of the functionalities provided by the openCV framework through its java wrapper (javaCV).

In chapter two the basics of image processing are covered. Also a brief comparison of available image processing frameworks is presented, and a more detailed description of openCV framework is given. Chapter three contains detailed description of recognition algorithm itself, along with its subsets and issues. In chapter four results and implemented algorithm is discussed and compared with other possible solutions. At last, final chapter (five) concludes the subject, states the advantages and disadvantages of the presented work, and suggests possible topics for further research.

Page 38: Case Mobile

108 CASEmobile

2. DIGITAL IMAGE PROCESSING AND DATA EXTRACTION ON MOBILE PLATFORMS

2.1 Basic concepts

Digital image processing is a term describing usage of computer algorithms on digital images in order to achieve certain goal, such as color correction, perspective modification, distortion etc., by modifying binary source data. Digital image is an image f(x,y) that has been discretized both in spatial coordinates and in brightness. It’s represented by a 2D integer array, or a series of 2D arrays, one for each color band. The digitized brightness value is called grey level [1]. Each pixel of image represents part of an object, which has been illuminated during the image capturing process. Illuminating light has been partly absorbed and partly reflected, causing different color representation. Reflected light reaches camera sensors and is being recognized. Each digitalized pixel is holding information about each color channel (e.g. in RGB color system, each pixel holds information about red, green and blue channel, which combined result in final color of that pixel). Additionally, each pixel can carry information about fourth, alpha channel, which is used for defining image transparency settings.

Image processing is still mostly used in industry, entertainment and marketing (e.g. [2], [3], [4]), image and video editing software (e.g. [5]), and, still in very small percentage, education [6]. It’s important to emphasize usage of digital image processing in biometrics, especially in face recognition, age and gender estimation and other fields. Open source biometric Recognition project OpenBR is developing communal biometrics framework supporting the development of open algorithms and reproducible evaluations, on top of the OpenCV library [7]. Image processing is key element of modern video surveillance (e.g. [8]), real time traffic monitoring (e.g. [9]) and drowning detection systems (e.g. [10]), but also some of software that help people with disabilities (e.g. Camera Mouse by Boston College [11]). Data extracting from images also is field of utilization digital image processing, as it is process of recognizing patterns in images and creating digital data out of them such as vectors and/or arrays. For example, if bingo card is scanned and processed to discover marked numbers, data about this card is being extracted and digitalized using digital image processing. Similarly, in this paper, process of data extraction by using digital image processing of exam scorecards will be presented. Process will be broken in three parts: Cropping image to fit area of scorecard answers, perspective correction as preparation for evaluation algorithm and evaluation algorithm itself.

2.2 Image processing frameworks

Image processing is available feature of many programming languages (Python, Java, MATLAB …), but powerful and fast processing is mostly done in C++. While one can choose to write program from scratch, many libraries and frameworks are available with precisely developed functions for different processing tasks. There are several popular libraries that offer functionalities for computer vision and image processing. A brief comparison of such libraries is given in Table 1.

Sinha [12] conducted performance comparison between 3 image processing frameworks: OpenCV, LTI and VXL. The results presented in Figure 1 show that OpenCV is faster than LTI and VXL, especially if used with Intel Performance Primitives. Comparison has been taken on Pentium M 1.7GHz and four tests were done:

2D DFT: Forward fourier transform of a 512×512 image

Resize: 512×512 to a 384×384 image, bilinear interpolation. An 8-bit, 3 channeled image was used

Optical flow: 520 points were tracked with a 41×41 window and 4 pyramid levels

Neural net: the mushroom benchmark of FANN

Library Written

in Language support

OS support License

OpenCV [13]

C++

Java (JavaCV),

.NET (EmguCV),

Python, MATLAB,

C++, C

Windows, Android, Maemo,

FreeBSD, OpenBSD, iOS, BlackBerry 10,

Linux, OS X

BSD

CImg [14]

C++ C++ Linux, Solaris,

OS X CeCILL license

Ccv [15]

N/A Flash Linux, OS X,

Windows LGPL

FastCV [16]

N/A C++

Windows, OS X, Linux,

Android, Windows Phone

8

FastCV License

Agreement

LTI-Lib [17]

C++ C++ Linux, Windows GNU Lesser

General Public

VXL [18]

C++ C++ Windows, Linux,

Solaris VXL License

Aforge [19]

C# C# Windows,

Windows Phone LGPL v3

Table 1 Listing of available image processing libraries. Supported OS for mobile devices are bolded

Figure 2 OpenCV vs VXL vs LTI: Performance comparison (less is better) [12]

2.3 OpenCV library

One of the most popular and widespread libraries certainly is OpenCV (Open Source Computer Vision Library), an open source computer vision and machine learning software library, built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial projects [13].

Library itself has more than 2500 optimized algorithms, including comprehensive set of both classic and state-

Page 39: Case Mobile

CASEmobile 109

of-the-art computer vision and machine learning algorithms. These algorithms can be used to detect and recognize faces, identify objects, classify human actions in videos, track camera movements, track moving objects, extract 3D models of objects, produce 3D point clouds from stereo cameras, stitch images together to produce a high resolution image of an entire scene, find similar images from an image database, remove red eyes from images taken using flash, follow eye movements, recognize scenery and establish markers to overlay it with augmented reality, etc.

OpenCV is written natively in C++, but it has several wrappers which expose OpenCV functions in different languages and different platforms. Some of them are EmguCV for .NET C#, JavaCV for Java, OpenCV for Android SDK etc. OpenCV is very large open source project, with more than 13.000 commits on GitHub, committed by more than 200 contributors. Except individual contributors, Corporate contributors such as Intel Inc. and Google Inc. are also involved in OpenCV development [20].

There are several reasons why we decided to use OpenCV:

Support for mobile platforms – only OpenCV, FastCV and Aforge explicitly state support for mobile operating systems, while only OpenCV and FastCV support Android.

Licensing – OpenCV has more liberal licensing policy (BSD) than FastCV (FastCV License Agreement).

Community: OpenCV has significantly larger communit with more than 47 000 community users and over 7 000 000 downloads.

Contributors: OpenCV is actively maintained by more than 200 contributors, both individuals and companies.

After we’ve selected OpenCV, it was then a matter of choice wether we will use OpenCV with C++ (Android NDK) or with Java (JavaCV wrapper). We have chosen JavaCV mainly because it was much easier to configure the whole project to work with JavaCV, and the syntax was more familiar to us, since Java is used for Android development.

3. ALGORITHM

3.1 Problem description

In this section we will describe the algorithm developed as a part of the PEAS (Personal Exam Assistant) system. The implementation targets Android mobile platform, so we decided to utilize popular OpenCV image processing framework through Java wrapper (JavaCV).

The main goal of this algorithm is to detect the hand-marked answers on scorecard paper sheet. Scorecard sheet itself contains arbitrary number of initially unfilled square fields which represent possible answers to particular questions. User is required to fill (mark) by hand those square fields which according to him represent correct answers. Such completed scorecard is an input to our algorithm.

In order to detect marked answers on scorecard, user takes a picture of it using its phone camera. Now, the first issue that appears here is the possibility the picture is not taken from proper undesirable perspective, so perspective must be corrected (Figure 2) and the image prepared. After that, the square fields’ detection process

is started. The last step is to evaluate the color of detected squares, and to see if it can be considered as marked square.

The following table lists and describes the most important OpenCV functions and functions developed by us:

Name Description Source

cvFindContours

int cvFindContours(CvArr*

image, CvMemStorage*

storage, CvSeq**

first_contour, int

header_size, int mode, int

method, CvPoint offset)

The function retrieves

contours from the binary

image

Open CV

getPerspectiveTrans

form

Mat

getPerspectiveTransform(In

putArray src, InputArray dst)

Calculates a perspective

transform from four pairs of

the corresponding points

Open CV

cvWarpPerspective

Void

cvWarpPerspective(const

CvArr* src, CvArr* dst, const

CvMat* map_matrix, int

flags, CvScalar fillval)

Applies a perspective

transformation to an image

Open CV

getLinesFromImage

List<Line>

getLinesFromImage(IplImag

e src, int cannyTreshold);

Retrieves the list of lines

detected on the image

Our

getCornerPoints

List<Point>

getCornerPoints(IplImage

src,List<Line> lines, double

minTreshold)

Retrieves the list of four

corner points from top left to

bottom left one

Ours

getAverageColor

int

getAverageColor(IplImage

img, int x, int y, int width, int

height, int padding)

Retrieves the RGB value of

average color in forwarded

region

Ours

analyzeArea

boolean

analyzeArea(CvRect rect,

IplImage img, int

thresholdTrue)

Retrieves the true if the

answer is marked or false if

answer is not marked.

Ours

Table 2 Main functions used to implement algorithm

Page 40: Case Mobile

110 CASEmobile

3.2 Perspective correction algorithm

Since the answer detection algorithm needs answer square fields to be mapped in a grid, it may be necessary first to correct the image's perspective in order to put the grid back in normal position, as shown in Figure 2.

Figure 3 Perspective correction

The whole perspective-correction process can be divided in few steps:

1 Contour detection █

2 Frame recognition █

3 Corner calculation █

4 Corner position detection █

5 Perspective transformation █

After the image was grayscaled, first we have used openCV's function 'cvFindContours' to get all of the contours in the image. The function usually finds large number of contours, depending on the image size and complexity. But the biggest contour in the image is the frame which contains answers grid. Then it is simply a matter of getting the contour with biggest calculated area.

After the frame has been found, we crop the image for easier handling (fewer pixels to worry about). And then we try to detect the lines on the frame. We also have to specify minimum length in pixels for object to be considered as a line. We use minimum of 200 pixels. After the lines get detected, in order to get the frame corners, it is necessary to calculate line intersections and sort them by their coordinates to know which corner belongs to which side.

Figure 4 Perspective correction process steps

Furthermore, the only remaining thing is to insert the original image and its frame corners as parameters for the openCV functions 'getPerspectiveTransform' and 'cvWarpPerspective', and we get the transformed image as a result.

3.3 Algorithm for detecting question squares

The input for this part of the algorithm is the image of the cropped frame, reduced to a fixed width and height. Coordinate (0,0) representing the upper-left corner of the frame with the answers is known. Since the image is always the same size, we know exact distance from left and upper edge of the frame to first square field, i.e. we know the exact lengths of a and b. Also the width and height of the square are fixed, so the entire area of the first square can be calculated.

Figure 5

Two more values are required: the distance from the upper-left corner of one square to upper-left corner of the first square to the right c, and the distance from the upper-corner of one square to upper-corner of the first square below d. Using aforementioned values, the exact positions and areas of all square fields are calculated.

Once all square fields are known we simply iterate through questions and answers and check whether the square representing an answer is marked or not. A simple pseudo-code representation of the algorithm is stated below:

3.4 Algorithm for recognizing answers

Input to the algorithm is a rectangle object containing all square fields (answers) in one row (question). As mentioned before, square position is calculated relatively to the starting edge of base rectangle. At the beginning, average color of all squares is calculated, so it can easily be determined if square is marked (i.e. color is darker than average color of base rectangle) or not.

Figure 5 visualizes conceptual steps of detecting marked answers. True problem is not to detect white and black squares, because there are no absolutely black or white ones. Trick is to determine darker and lighter squares, in comparison to average color of common area of all squares. We could use average color of entire scorecard, but shadows significantly affect detection, so localization of detection improves results. In step 1, safety padding is added, to ensure that average color will take enough white color in detection (if all squares are marked, average color will

FOR each question

averagecolor=getAverageColor

FOR each answer

isMarked=analyzeArea(area,averageColor)

if isMarked is true

answer is marked

else

answer is not marked

Page 41: Case Mobile

CASEmobile 111

be dark, and detection won’t be so efficient). In second step, average color is calculated, and compared with each square in step three.

Figure 6 Steps for detecting marked answers

3.5 Testing example

Figure 7 Capturing the scorecard

Figure 8 Processing captured image

For demonstration of our implementation, we will showcase few screens of our application PEAS which uses that implementation and whose source code can

be found at BitBucket*. Precondition for usage is

obtaining the exam metadata by scanning QR code at the beginning of the exam. Information used in square detection algorithm is available in that metadata. Once exam is finished, user captures scorecard with PEAS application and photo (i.e. digital image) processing begins.

After processing is done, recognized answers are displayed as overlay layer with green squares over the detected answers. User then checks marked answers and confirms that green marked square fields really are chosen answers. After validation, answer data is sent in HTTP request to web service which calculates the final score. Response contains data about exam result which is then shown in styled form of radial graph.

Figure 9 Validation of marked answers

Figure 10 Result presentation

4. DISCUSION

The image processing and computer vision combined with mobile devices is still a new field. That said, there are certain technical and other issues that should be taken into consideration. For example, we have witnessed that only a part of image processing frameworks are suitable to be used on mobile platforms. While most of them are developed in C++ programming language, few of them offer wrappers which ease the use of frameworks in mobile applications developed in other languages such as Java or C#.

The wars of incompatible mobile platforms are taking their toll here as well. To our best knowledge, OpenCV came the farthest to support multiple platforms. But it is at least very questionable if the same image processing framework could be used to develop native mobile application for all major mobile platforms. Also, when choosing appropriate framework for our initial algorithm implementation on Android mobile platform, we witnessed a lack of proper API documentation in some frameworks, which really makes the use and configuration of framework difficult.

In a past few years the processing capabilities of mobile devices have grown exponentially, however, image processing is still a demanding task. So in order to assure satisfactory performance, and in the same time not to overload mobile devices battery, an optimized algorithm for image processing is a top priority.

* https://bitbucket.org/dmacan23/aes_ieee

Function analyzeArea Input: Area to analyze, threshold colorValue=calculate average color if colorValue < threshold return true else return false

Function getAverageColor Input: Area to analyze, padding Include padding into area avgValue = 0 FOR each pixel in area curValue = RGB value of current pixel

avgValue = avgValue + curValue counter = counter + 1 avgValue = avgValue / count return avgValue

Page 42: Case Mobile

112 CASEmobile

The scorecard image that needs to be processed by our algorithm is taken by mobile phone camera. The quality of taken image can vary depending on quite a few factors. A lot of these factors that can significantly influence the image quality are not in our control. For example, on mobile market there is a large number of different mobile devices, with different properties and camera quality; the person that takes a picture can take blurred picture, or the image perspective can be shifted; improper lightning in the room, reflections or shades can also make the content of scorecard hard to detect; the marked answers could have to small contrast etc. Neutralizing the unwanted impact of aforementioned factors is not an easy task. We managed to mitigate the influence of taking picture in a wrong perspective by implementing algorithm for perspective correction, but dealing with reflection, shades, lightning, and contrast issues is something that we need and plan to improve.

Although it certainly needs to be improved, our algorithm is implemented in fully functional mobile application, and even now gives satisfactory results in recognizing answers on scorecard sheet. Also, in our opinion, both the algorithm as a whole and the parts of the algorithm can be applied in different contexts. The perspective correction algorithm, the algorithm for detecting square fields, and the algorithm for detecting marked answers can be easily adapted and used in many similar mobile applications.

5. CONCLUSION

This paper summarizes our efforts in developing algorithm for detecting answered questions on scorecard paper sheet, using image processing on mobile devices. Image processing and computer vision is an exciting field in computer industry, which becomes even more exciting when combined with mobile devices. As we already stated, applications of these two technologies combined are numerous and possible in different areas of industry, education, government tourism etc. We believe this field is yet going to show its full potential.

In algorithm implementation we used popular OpenCV framework through its JavaCV wrapper, since we found it to be fast, widespread, well documented and cross-platform framework. However, we also identified several issues and challenges when developing image processing in mobile applications. Also, we plan to improve our algorithm in several aspects: neutralizing shading, lighting, bad contrast, and reflection negative impacts; optimizing performance; delivering more responsive, real-time validation of marked answers.

The developed algorithm is implemented in fully functional Android mobile application which we demonstrated in Testing example section.

Also, we identified few interesting topics for future research on image processing mobile applications: feature and performance comparison of available frameworks; difference in performance between wrappers and C/C++ implementation; native mobile vs web applications; cross-platform development; optimization of image processing algorithms.

References:

1 M. Petrou, Image processing: the fundamentals, 2nd ed. Chichester, U.K: Wiley, 2010.

2 “▶ Place IKEA furniture in your home with augmented reality - YouTube.” [Online]. Available: http://www.youtube.com/watch?v=vDNzTasuYEw. [Accessed: 17-May-2014].

3 “Google Glass.” [Online]. Available: http://www.google.com/glass/start/. [Accessed: 17-May-2014].

4 “Aurasma Reviews | edshelf.” [Online]. Available: https://edshelf.com/tool/aurasma. [Accessed: 17-May-2014].

5 “Creative Cloud now includes Creative Suite Master Collection and Design Premium features.” [Online]. Available: http://www.adobe.com/products/cs6.html?promoid=JOLIS. [Accessed: 17-May-2014].

6 “How To Use Augmented Reality In Education - Edudemic.” [Online]. Available: http://www.edudemic.com/augmented-reality-in-education/. [Accessed: 17-May-2014].

7 “OpenBR | Home.” [Online]. Available: http://openbiometrics.org/. [Accessed: 17-May-2014].

8 Eric Chu, Jim He, and Andrew Spencer, “OpenCV and TYZX: Video Surveillance for Tracking.” [Online]. Available: http://prod.sandia.gov/techlib/access-control.cgi/2008/085776.pdf. [Accessed: 17-May-2014].

9 Kim-Sung Jie and Ming Liu, “Computer Vision based Real-Time Traffic Monitoring System.” [Online]. Available: http://eng.monash.edu.au/civil/assets/document/research/centres/its/confs-workshops/archive/liu-tram.pdf. [Accessed: 17-May-2014].

10 “Drowning detection, pool surveillance with Poseidon.” [Online]. Available: http://www.poseidon-tech.com/us/system.html. [Accessed: 17-May-2014].

11 “Camera Mouse.” [Online]. Available: http://www.cameramouse.org/index.html. [Accessed: 17-May-2014].

12 “OpenCV vs VXL vs LTI: Performance Test | AI Shack.” [Online]. Available: http://www.aishack.in/2010/07/opencv-vs-vxl-vs-lti-performance-test/. [Accessed: 15-May-2014].

13 “OpenCV,” OpenCV, 2014. [Online]. Available: http://opencv.org/. [Accessed: 15-May-2014].

14 “The CImg Library - C++ Template Image Processing Toolkit.” [Online]. Available: http://cimg.sourceforge.net/reference/group__cimg__faq.html#ssf12. [Accessed: 16-May-2014].

15 “Community Core Vision.” [Online]. Available: http://ccv.nuigroup.com/. [Accessed: 16-May-2014].

16 “Computer Vision (FastCV) - Mobile Technologies - Qualcomm Developer Network.” [Online]. Available: https://developer.qualcomm.com/mobile-development/add-advanced-features/computer-vision-fastcv. [Accessed: 16-May-2014].

Page 43: Case Mobile

CASEmobile 113

17 “LTI-Lib.” [Online]. Available: http://ltilib.sourceforge.net/doc/homepage/index.shtml. [Accessed: 16-May-2014].

18 “VXL - C++ Libraries for Computer Vision.” [Online]. Available: http://vxl.sourceforge.net/. [Accessed: 16-May-2014].

19 “aforge - AForge.NET Framework - Google Project Hosting.” [Online]. Available: https://code.google.com/p/aforge/. [Accessed: 17-May-2014].

20 “OpenCV - Contributors - OpenCV DevZone.” [Online]. Available: http://code.opencv.org/projects/opencv/wiki/Contributors?version=2. [Accessed: 17-May-2014].

21 “Itseez/opencv · GitHub.” [Online]. Available: https://github.com/Itseez/opencv. [Accessed: 17-May-2014].

Information on authors:

Alen Huskanović

e-mail: [email protected]

Alen Huskanović is a regular student of the third year of undergraduate study Information Systems at the Faculty of Organization and Informatics in Varazdin. He has participated in various national and international competitions, among which stands out IEEEmadC international competition for the design of mobile applications where he won first prize. Actively working on the system PEAS with whom he came to Croatian finals of Microsoft Imagine Cup. He is primarily engaged in the development of applications for the Android operating system.

David Ante Macan

e-mail: [email protected]

David Ante Macan is a third year undergraduate student of Information Systems at Faculty of Organization and Informatics. He has participated in various competitions, including the Croatian Microsoft Imagine Cup finals, won the best design award at IEEEmadC contest, won the third place at Infinum student Hackathon 2014, etc. His main area of interest is mobile development, especially Android. He is actively working on several projects, including the Personal Exam Assistant (PEAS) project at Faculty of Organization and Informatics. He is also a member of IEEE Institute and is one of the student coordinators and founders of the Laboratory for mobile technologies (MT Lab) at Faculty of Organization and Informatics.

Zoran Antolović

e-mail: [email protected]

Zoran Antolović is a third year undergraduate student of Information Systems at Faculty of Organization and Informatics, University of Zagreb. Primarily interested in web development and design, he participated in various projects, such as Microsoft Imagine Cup (finals 2014), Best Code Challenge 04 (top 10 2014), first place at Infinum Student Hackathon 2014, first place in Best design category at IEEEmadC international competition with PEAS mobile application. With other students, he has participated in Nestala djeca (missing childrens) project, developing entire web application and web services for mobile application.

Boris Tomaš

e-mail: [email protected]

Boris Tomaš, M.A. is a Junior researcher and Teaching Assistant at the Faculty of Organization and Informatics, University of Zagreb where he works at the Department of Information System Development. Boris' assignments at the Faculty are laboratory sessions delivered on the courses Geography Information Systems and Software Engineering. Fields of interest are: software development, mobile technologies, geoinformatics, bioinformatics, artificial intelligence, application marketing, Internet marketing. During his work career he worked on several projects in various positions. Boris is currently a doctoral student at the Faculty of Organization and Informatics, University of Zagreb. For his academic achievements he received Faculty Dean's award and University Rector's award.

Marko Mijač

e-mail: [email protected]

Marko Mijač, as of July 2011 works at the Faculty of Organization and Informatics in Varaždin as a project KI Expert 2012, project MEDINFO associate, and as a teaching assistant on courses related to software engineering and information systems. Prior to his current employment he worked as a developer of intranet production planning system at Boxmark Leather d.o.o. He is interested in web, desktop and mobile applications development in various platforms and technologies.

Faculty of Organization and Informatics

Pavlinska 2

42000 Varaždin

tel: +385 42 390 853

fax: +385 42 213 413

Page 44: Case Mobile

114 CASEmobile

Page 45: Case Mobile

CASEmobile 115

NOVI KONCEPT RAZVOJA APLIKACIJE - ZA PROGRAMERE I ONE KOJI TO NISU

NEW CONCEPT OF APPLICATIONS DEVELOPMENT – FOR DEVELOPERS AND NON-DEVELOPERS

Ivan Curić, Tomislav Bronzin

SAŽETAK:

Što je zajedničko, a po čemu se razlikuju novi alati za razvoj aplikacija: Windows App Studio, TouchDevelop, Project Siena i CodeAnywhere?

Zajedničko je to što svi alati (osim zadnje spomenutog CodeAnywhere) omogućavaju razvoj Windows Phone ili Windows 8/8.1/RT aplikacija na tabletima, a mogu ih koristiti i ljudi koji nisu razvojni inženjeri. Svi alati koriste računalni oblak kako bi omogućili dvije stvari: dostupnost razvojne okoline s (gotovo) bilo kojeg uređaja, s bilo koje lokacije prvenstveno na tabletima i velikim oslanjanjem na računalni oblak – što za pohranu programskog koda, što kao alat za izvršavanje i debugging. Većina njih odlično koristi novo sučelje upravljano dodirom (touch) ili olovkom (stylus), dok samo CodeAnywhere se koncentrira više na tipkovnicu i pisanje „pravog koda“. App Studio omogućuje generiranje izvornog programskog koda po programskom predlošku MVVM, pa ga razvojni inženjeri mogu dalje koristiti u Visual Studio-u, dok TouchDevelop generira skriptu koja se može pokrenuti na webu. Rezultati ovakvog načina izrade aplikacija su efektne i brzo napravljene aplikacije upravljane dodirom, koje možete publicirati u trgovine aplikacija.

Ključne riječi: Windows App Studio, TouchDevelop, Project Siena, CodeAnywhere

ABSTRACT:

What is common and what is different about new tools for application development: Microsoft App Studio, TouchDevelop, Project Siena and CodeAnywhere?

The common factor is that all tools (except for the last mentioned CodeAnywhere) enable the development of Windows Phone and Windows 8/8.1/RT applications on tablets, and can be used by people who are not developers. All tools use cloud computing to enable two things: the availability of development environments on (almost) any device from any location, primarily on tablets and heavy reliance on cloud computing - to store program code and as a tool for executing and debugging. Most of them has used new touch-controlled interface (touch) or pen (stylus), while only CodeAnywhere concentrate more on the keyboard and writing "real code". App Studio allows you to generate source code that follows MVVM programming pattern, so it can be further developed using Visual Studio, while TouchDevelop generates a script that can be run on the web. Results of this approach to application developing are effective and quickly made apps controlled by touch, which can be published to app stores.

Keywords: Windows App Studio, TouchDevelop, Project Siena, CodeAnywhere

1. INTRODUCTION

In recent years we have witnessed the overwhelming success of smartphones and tablet devices, as well as the rapid development of mobile platforms. Today we have some excellent mobile operating systems like iOS, Android and Windows Phone, as well as a multitude of excellent smartphone devices available in the market at affordable prices. In addition to smartphones, we have tablets, which are also very popular and use the same platform as the smartphones. These platforms count billions of users who own a smart device and use apps daily and is increasingly replaced PC devices that falls into the background. Mobile devices are first choice and, in less developed countries, possibly the only computing devices which virtually all people will own and carry with them all the times. [2]

Most people wants to make their own apps, but does not have proper skills and knowledge for that. They are not prone to source code writing and making an app in that way, instead of that they are used to nice, touch friendly user interface and find it convenient to build an app by dragging a building blocks just like playing a video game.

There are several Microsoft developed platforms that makes that possible, like Windows App Studio, TouchDevelop and Project Siena. You can use those platforms to quickly build an app by just clicking and connecting different building blocks, and without any programming skills needed.

On the other hand, CodeAnywhere is completely different and requires programming skills. It is a multi-platform cloud based code editor that enables you to make apps from your browser, no matter what device you are using. CodeAnywhere enables developers to write source code on any device and in any place so it represents a new concept for developers.

This paper shows new concepts of applications development using touch-enabled devices and cloud computing that enables you to make apps using any device and from any location, with or without programming skills necessary. Paper represent a new concepts in applications development that shifts from traditional source code writing on PCs using keyboard and mouse, and shows that applications development is evolving to easier and user friendly experience, that does not necessary involve strong programming skills and knowledge.

Page 46: Case Mobile

116 CASEmobile

2. WINDOWS APP STUDIO

Windows App Studio is the easiest way to start building apps for Windows and Windows Phone in a few easy steps. Windows App Studio lets you swiftly build Windows and Windows Phone apps to test, publish, and share with clients, co-workers, friends, and family. It enables you to create app with few clicks of a mouse and data entry, without the need for real programming knowledge or environment. That way it is best suited for people without experience in software development, who wants to make functional apps and publish them to Windows Store. [9]

Windows App Studio is a web-based development platform that uses point-and-click development with no coding required. It targets Windows platform exclusively and is useful for information and promotion type apps, such as: fan apps (bands, sports teams, movies), guides (vacation destinations, city guides), collections (recipes, photos, videos), store apps (product lists and information) and event apps (wedding or party). If features in App Studio are not enough for your app, or you want to add some new complex features, the platform enables you to extend or enhance your app with code. [7]

App Studio can also be used to make prototypes of apps, to make better understanding of client needs and requirements, so that app can be represented to a client as soon as possible. And when you're ready to try add advanced programming features, Windows App Studio generates your source code - a feature no other app-builder tool provides.

With Windows App Studio, you can:

Build a universal Windows app for Windows Phone 8.1 and Windows 8.1 in a single session

Download your app directly onto your Windows device to share

Download the source code so that you can extend it with Visual Studio

Download the app package so that you can publish your app to Store through Dev Center

You can develop apps in App Studio by selecting one of existing templates that can help you build app even faster. Next step is to provide app title, description and logo. These information are also used to publish app to Windows Store. App content can be provided from several data sources like Flickr, YouTube, Rss Feed, Facebook, Instagram, Bing, HTML, and from user defined data collections.

Figure 11- Windows App Studio look and feel

App Studio also enables you to design your app by choosing custom color theme, and by providing splash screen, lock screen and logo images, and by designing app tile.

3. PROJECT SIENA

Microsoft Project Siena (code name) is a new technology for business experts and other app imaginers, which enables them, without any programming, creation of apps that harness the power of corporate data and content, as well as web services. [3]

Project Siena is a Windows Store App that enables you to create a Windows Store apps. It is a visual app designer that enables you to build an app by selecting and placing an element on app screen, and visualizing provided data, without any programming skills needed.

Figure 12 - Project Siena app look and feel

Siena is designed to create apps that are more document-like and highly visual, with a canvas for inserting images, buttons, shapes, videos, and more.

It’s very similar to Microsoft’s Windows App Studio that lets anyone create apps on the web. The difference is that Siena provides similar experience but as a touch-friendly environment on a tablet or PC running Windows 8.

Examples of the kinds of apps people have been building:

Apps for consuming information, such as product catalogs and video-based lesson plans.

Apps for on-the-spot decisions, such as adjusting insurance claims and accessorizing an outfit.

Apps for tasks that involve capturing pictures, audio, handwriting, and other real-world input.

These are apps for the device-first and cloud-connected world, with the potential to transform today’s business processes and customer interactions.

Building a Siena app is as easy as editing a PowerPoint presentation or Excel spreadsheet. You place some visuals on a canvas. You hook them up to your data or favorite services. You customize how your app looks and works. Then, if you need special logic and intelligence, you write some Excel-like expressions. You can use your app immediately, or share it with colleagues or the world. [5]

Siena works well with corporate and web data: SharePoint lists, Excel and Azure tables, RSS feeds and REST services. The authored apps are IT-friendly. Since the output is just HTML/JavaScript, developers can also open up and extend them in their favorite HTML/JavaScript programming tools, if needed.

Project Siena is still in beta phase, and is constantly upgraded. These are some of the new features that can be expected:

Apps that run across multiple device platforms Support for global languages Connections to Office 365 services

Page 47: Case Mobile

CASEmobile 117

Ever-easier app building with contextually generated rules

The main attractions of Project Siena are:

Conceptualize, validate, and build your app ideas as easily as editing a document.

Connect to corporate and web data. Compose rich interactive visuals to create custom,

unique apps. Add business logic and intelligence using the power

of Excel expressions. Use the app yourself, and share it with colleagues

or the world.

4. TOUCHDEVELOP

TouchDevelophttp://en.wikipedia.org/wiki/TouchDevelop - cite_note-1 is an interactive development environment and a visual programming language being developed at Microsoft Research. TouchDevelop is a development environment for mobile and Web apps that runs on phones, tablets, PCs, and even giant touchscreens, and enables you to create fun games and useful tools regardless of your working environment. It lets you create apps on iPad, iPhone, Android, PC, Mac and Windows Phone. [8]

In the TouchDevelop programming environment you write scripts by tapping on the screen. You do not need a separate PC or keyboard. Its programming language and code editor have been built from scratch around the idea that all code is entered via a touchscreen, without a keyboard.

Figure 13 - TouchDevelop programming environment

Scripts can perform various tasks similar to regular apps. Any TouchDevelop user can install, run, edit, and publish scripts. You can share scripts with other people by publishing them to the TouchDevelop script bazaar, by submitting them as an app to the Windows Store or Windows Phone Store, or by sharing them as cross-platform HTML5 Web Apps. [4]

TouchDevelop uses the latest web technologies that can run in most modern web browsers to bring a cloud-connected, touch-friendly app creation environment to every device, and it also works offline. It enables users to program their mobile devices directly on the devices.

TouchDevelop scripts are written and run in the TouchDevelop IDE, which can be installed on either a Windows Phone or a web browser for other platforms such as Android and iOS. To ease programming on mobile devices, the IDE provides a semi-structured code editor, which presents users with a small number of possible choices (e.g., different types of statement) at each step. In this manner, the users build the skeleton of the script via touching to select choices, leaving only variable names and expressions for typing. [6]

In addition to its use as a tool for creating application programs, TouchDevelop has been used to teach

programming and mobile device technology at schools, colleges and universities.

5. CODEANYWHERE

Codeanywhere is a multi-platform cloud based code editor that enables you to write code and collaborate no matter where you are or what device you have with you. Codeanywhere, a self-proclaimed Google Docs for coders, wants to become the defacto standard for code development on the go and enables you to write code and fix bugs in the cloud. It comes really handy in a situations where you do not want to bring your programming device with you, instead of that you can access your projects and code on the go, and from virtually anywhere using this cloud solution.

Codeanywhere is a text, code and markup editor that has been redesigned and reengineered to be light, fast, and mobile-friendly. It enables you to connect to your FTP, SFTP Servers, Dropbox or Github account and easily manipulate your resources, folders or files just with the swipe of your finger. It also enables you to share and collaborate on projects or just a single file, from wherever you are, and to quickly edit code with special keyboard that has been customized for developers on the go. Codeanywhere makes developers forget what device they are working on and let them concentrate on getting work done on any device like iPad, iPhone, Android or the desktop. [1]

Codeanywhere offers iOS, Android, Blackberry and Windows Store apps in addition to a web option. Some of the main features include:

Code Editor Image Viewer FTP Client SSH Dropbox/GitHub Integration

6. CONCLUSION

As the use of smartphone and tablet devices escalated in the last years, there is a need to new, intuitive and user friendly environments to make apps for those devices. Some common requirements are set for those new concepts, like:

Provide a way to make apps without programming skills necessary

Provide a platform for fast app creation using predefined app templates

Provide a way to make apps using touch-enabled devices like smartphones and tablets

Microsoft made strongest effort here, providing several platforms and concepts for this kind of app development. By that, they have enabled an easy way for their users to present various content on their platforms, Windows Phone and Windows 8.xx.

The common factor of all presented tools, is that all tools (except for the last mentioned CodeAnywhere) enable the development of Windows Phone and Windows 8/8.1/RT applications on tablets, and can be used by people who are not developers. All tools use cloud computing to enable two things: the availability of development environments on (almost) any device from any location, primarily on tablets and heavy reliance on cloud computing - to store program code and as a tool for executing and debugging. Most of them has used new touch-controlled interface (touch) or pen (stylus), while only CodeAnywhere concentrate more on the

Page 48: Case Mobile

118 CASEmobile

keyboard and writing "real code". App Studio allows you to generate source code that follows MVVM programming pattern, so it can be further developed using Visual Studio, while TouchDevelop generates a script that can be run on the web. Results of this approach to application developing are effective and

quickly made apps controlled by touch, which can be published to app stores.

It remains to see how popular these platforms will be, and will users accept them as a new concepts in applications development. But one thing is for sure, they all represent the direction in which application development is developing.

References:

1 CodeAnyWhere Inc. webpages. [Online] Available: https://codeanywhere.com/. [Accessed: 26-May-2014].

2 I. Curić and D. Adamec, “Development of web applications adaptive to different screen sizes (Responsive Web Apps)”, in Razvoj poslovnih i informacijskih sustava CASE 25, Zagreb, 2013.

3 Microsoft Project Siena. [Online] Available: http://technet.microsoft.com/en-us/dn518139. [Accessed: 26-May-2014].

4 Microsoft Research: TouchDevelop. [Online] Available: http://research.microsoft.com/en-us/projects/touchdevelop/. [Accessed: 27-May-2014].

5 S.Somasegar, “Project Siena Beta 2: Enabling business users to create apps connected to enterprise services, web and social”, 2014. [Online] Available: http://blogs.technet.com/b/projectsiena/archive/2014/03/24/project-siena-beta-2.aspx. [Accessed: 26-May-2014].

6 Sihan Li, Tao Xie, and Nikolai Tillmann, A Comprehensive Field Study of End-User Programming on Mobile Devices, in Proc. IEEE Symposium on Visual Languages and Human-Centric Computing (VL/HCC 2013), September 2013.

7 Tomlinson, Bryan, “Introduction to Mobile App Development”, 2013. [Online] Available: https://www.facultyresourcecenter.com/curriculum/9175-introtoapps.aspx. [Accessed: 26-May-2014].

8 TouchDevelop website. [Online] Available: https://www.touchdevelop.com/. [Accessed: 26-May-2014].

9 Windows App Studio How To. [Online] Available: http://appstudio.windows.com/Home/HowTo. [Accessed: 26-May-2014].

Information on authors:

Ivan Curić, mag.inf.

e-mail: [email protected]

Ivan Curić is program manager in CITUS Ltd. and master of informatics in fields of information and software engineering. He has gained practical knowledge managing complete lifecycle of several important projects like Conference@Net web system for organizing conference and events, and C@N Motion - interactive multimedia kiosk that allows for managing content using hand gestures at distance, through Microsoft Kinect device. Development areas he is intensively engaged are development of Kinect application, ASP.NET MVC framework for web apps development and multiplatform development of mobile apps. Ivan is EUCIP and Microsoft certified, author of several professional papers in the field of information systems development and speaker on several conferences, like Mobility Day, MS WinDays, MS NetWork, KulenDayz, CASE.

Tomislav Bronzin, mag.ing.el.

e-mail: [email protected]

Tomislav Bronzin is Microsoft Most Valuable Professional and founder of CITUS, Microsoft Silver Partner Company that is specialized in software development, consulting and training. His specialty is development of distributed applications, focusing on Windows Mobile and Unified Communication. Tomislav is trainer and speaker at Microsoft conferences like Microsoft TechEd Europe, DevDays, PASS Europe, DevReach, WinDays, Sinergija, Vizija etc. He is teaching at several universities and mentoring student teams for Imagine Cup Championship. Tomislav is INETA Europe Vice President and organizer of http://www.mobilityday.com conference. He is author and one of the 4 MVP's and MCT's that are teaching atwww.developersbootcamp.com based on his experience as Solution Architect for projects like www.protectatwork.com. Protect@Work is distributed application based on most recent technologies like windows 8, mobile (all platforms) & cloud computing. Tomislav has been Microsoft Regional Director for 10 years (2003-2013).

CITUS Ltd.

Dragutina Golika 63

10000 Zagreb

e-mail: [email protected]

web: www.citus.hr

tel.: +385 1 3667 120

Page 49: Case Mobile

CASEmobile 119

KORIŠTENJE GOOGLE CLOUD MESSAGING SERVISA U ANDROIDU

USING GOOGLE CLOUD MESSAGING SERVICE IN ANDROID

Zoran Kos, Zlatko Stapić

SAŽETAK

Rad prikazuje mogućnosti korištenja Google Cloud Messaging (GCM) servisa za Android platformu, te koji omogućuje developerima da pomoću web servisa šalju notifikacije i podatke instaliranim aplikacijama, na pametnim i mobilnim uređajima ili tabletima. GCM pritom vodi brigu o stanju u kojem se mobilni uređaj nalazi, a asinkrona komunikacija je moguća i u suprotnom smjeru, to jest od mobilne aplikacije prema servisu. GCM raspolaže s mnogo korisnih značajki poput „send to sync“ i „senddata“ mogućnosti, podrške za multicast poruke, rada u slučaju mirovanja, uporabu perzistentne veze (upotreba XMPP-a), upstream slanja poruka i sinkronizacije obavijesti na većem broju mobilnih uređaja. Također ova usluga se može iskoristiti za lociranje ukradenih telefona, daljinsko podešavanje telefona, slanje poruka prilikom postizanja određene razine u igrama itd. Ukratko, usluga GCM je odličan način za programere da upravljanju s provjerenim aplikacijama, ali sa sobom nosi i određene nedostatke jer je u zadnje vrijeme postala predmet računalnog kriminala.

ABSTRACT

This article presents the possibility of using Google Cloud Messaging (GCM) service for the Android platform. GCM provides programmers and developers the possibility to send notifications and data to smart phones’ or tablet’s installed applications, by means of using the Web services. It also takes care of the state in which the mobile device, and gives a possibility of asynchronous communication in the opposite direction – from mobile application to the service. GCM has many useful features such as: “Send to Sync” and “Send data” capabilities, support for multicast messages, delay while idle, the use of persistent connections (by using XMPP), the upstream messaging and synchronization notification across multiple android devices. Also, this service can be very useful for locating stolen phones, remote adjustment of the mobile device sending a messages when user reach a certain level in the game, and so on. Shortly, the GCM is a great way for Android developers to manage their applications, but it also has its disadvantages and it recently became the subject of cyber-attacks.

1. INTRODUCTION

Google cloud messaging (GCM) for the Android platform is a service that provides applications’ programmers and developers to communicate with applications installed on smart phones, tablets, Chrome

apps and extensions, from servers. GCM was officially presented in 2012. at Google I/O conference in San Francisco, California. The next year, at the same conference, new improvements were introduced (Google Developers, 2013). Through this service, it is possible to send a wide range of information, from

Figure 1 - GCM life cycle flow (HMKCode, 2014)

Page 50: Case Mobile

120 CASEmobile

ordinary notifications to the commands that are executed inside the application by providing fresh and up-to-date data for users. This service has been developed to assist developers in building apps whose communication or data transfer goes asynchronous in two directions, between service and applications on the same connection (push notification). This data could be a lightweight message telling the Android application that there is a new data to be fetched from the server (for instance, a "new email" notification informing the application that it is out of sync with the backend), or it could be a message containing up to 4KB of payload data (so apps like instant messaging can consume the

message directly) (Android Developers, 2014a). Google

uses GCM for the processing and sending instant notifications for many popular applications including Twitter, Facebook and Gmail. This applications use GCM to inform the users about: the friends that have checked in nearby; the received a message; any related notice with user profile.

The strength of this service can be seen in the fact that it can serve more than 200,000 push notification every second. This paper describes how the messaging works, and it consists of five sections. After this introduction the second section describes the main characteristics and components of which GCM is composed. The third chapter describes initial steps that have to be made on the client and the server side implementation of the GCM. It also describes what are user notifications and their role in the GCM. The fourth chapter shortly writes about the vulnerabilities and attacks that were recorded on GCM. At the end of this paper conclusion is given.

2. THE MAIN GCM CHARACTERISTICS

The GCM architecture is graphically presented in Figure 1 and it contains the three following main components:

Client Application – receives the message from GCM connection server initially sent by the application server and sends the new message to the same server.

3rd-

party Application server – receives the client app registration ID; based on the registration ID records in the database sends the message to the GCM connection server.

GCM connection server – receives the messages from the application server and sends these messages to the GCM enabled android devices.

Before using GCM there was the Android Cloud to Device Messaging (C2DM) service that helped sending data from servers to applications on the mobile devices. But with appearance of GCM, C2DM has been officially deprecated, meaning that the C2DM stopped accepting new users, denies new quota requests and has no new available features. The reason for deprecation was that GCM can be simply put to use. There is no signup form; no quotas or client login token, it takes 4.7 ms to deliver the messages, and all of this reduces battery usage and gives a rich set of new APIs. GCM also provides a client and server helper library which means that developers can easily write code. The GCM service is completely free and handles all aspects of queuing of messages and delivery to the target Android application running on the target device. Considering these changes it is not possible to establish interoperability between GCM and C2DM. All GCM major features that are new and make a difference in relation to C2DM are placed in Table 1:

GCM features and APIs

Simple API key

Sender ID

Canonical registration ID

Json format

Multicast messages

Time-to-live messages

Messages with payload

Send-to-Sync messages

Upstream messaging

Seamless multi-device messaging

Multiple senders

Table 1 – GCM features and APIs

Key Concepts of GCM are components, entities of GCM architecture and the credentials used for access authentication in different stages of GCM. Credentials can ensure that all components have been properly authenticated so that data transfer and messaging is going to the correct place and without delay. Credentials are the IDs and tokens used in different stages of GCM which are listed below (Android Developers, 2014a):

Sender ID – a project number given from API console, used in the registration process to identify a 3

rd-praty app server.

Application ID – located in manifest and identified by the package name. This ID ensures that the messages are targeted to the correct app.

Registration ID – issued by the GCM servers to the app that allows it to receive messages. This ID is tied to a particular app running on a particular device. 3

rd-party app server can identify each

device that has registered to receive messages for a given app. If client app no longer wants to receive messages it can unregister GCM.

Google User Account – used only if use’s Android API is lower than 4.0.4.

Sender Auth token – is an API key that is saved on the 3

rd-party app server. It gives app server

authorized access to Google services. The token is placed in the header of POST requests that send messages.

If we put attention on Figure 1 we can see the lifecycle flow of GCM which consists of three processes that are described in more detail below:

Enable GCM Send a message Receive a message

To enable GCM, client app that runs on mobile device calls register method which returns the register ID in order to receive messages. A 3

rd-party app server sends

messages to the device, and this process consists of several steps (Android Developers, 2014a):

Google checks and stores the message in case the device is offline.

When the device is online, Google sends the message to the device.

The system broadcasts the message to the specified app via Intent broadcast with proper permissions, so that only targeted app gets the message.

App processes the message.

Process “receive a message” consists of a sequence of steps starting from extracting the raw key/value pairs from the message payload. After that system transmits this key/value pairs to the targeted app as a set of

Page 51: Case Mobile

CASEmobile 121

extras to broadcast receiver. App then extracts raw data from this intent and processes the data. The app server sends a message to GCM servers. The described processes make the life-cycle of GCM which is shown in Figure 2:

Figure 2 – GCM Life Cycle Flow (freelancersnepal, 2014)

3. IMPLEMENTATION OF THE GCM

This chapter provides short guidelines, the developers should hold, in order to successfully implement the GCM. Before GCM can be used in java project, some steps should be taken. They are listed and explained below:

1 Installation of Google Play services SDK – provides the GoogleCloudMessaging methods and it can be used in combination with Eclipse ADT environment.

2 Creating a Google API project inside the Google Developers Console – it creates project ID and project number.

3 Enabling the GCM service API inside created project.

4 Creating a Server key – with option to whitelist specific IP addresses. This key is used by developer’s server app as a password when connecting to Google’s Command and Control server.

After successfully completing above steps GCM project in the API Console is created and it’s possible to start implementing GCM. Developers can thereby decide which of the available GCM connection servers will be used (HTTP or XMPP). Then, it is possible to start implementing an app server to interact with chosen GCM connection server or GCM-enabled app that runs on a device. Those who do not have own available 3

rd-

party app server can use upstream messaging (device-to-cloud) feature or user notification via Command and Control server (CCS is an XMPP endpoint that provides a persistent connection to Google server) by

becoming trial partner with Google available at given URL: https://services.google.com/fb/forms/gcml/.

3.1 How to implement GCM Client

As mentioned earlier in the previous chapter, the GCM client is GCM-enabled app that runs on mobile device

which uses GoogleCloudMessaging API. It is also

possible to use the client helper library that was offered in previous version of GCM but now it’s not recommended to be used because some methods in this library are deprecated. The following example shows how to implement GCM client in mobile device that runs on Android platform. For purposes of better presentation and programming, the next example parts of the codes are taken and modified from publicly available pages (tutorials) which can be found at (Android Developers, 2014b) and (Cambell, 2013). To implement a GCM client-side application, application must include code to register (Registration ID) and broadcast receiver to receive messages sent by GCM. In order to do that we can use the form shown in Fig. 3:

Figure 3 – Registration application form

Starting point is to include GoogleCloud Messaging

API (available within Google play services SDK) into the project. Without this API it is not possible to implement GCM on client side. The second point is writing permissions in the application manifest:

com.google.android.c2dm.permission.REC

EIVE – app can register and receive messages.

com.google.android.c2dm.intent.

RECEIVE – if set, only the GCM Framework can

send a message to it.

android.permission.INTERNET – for sending

registration ID to the 3rd

party server.

android.permission.GET_ACCOUNTS – if

mobile device is running on lower API then Android 4.0.4, GCM must require a Google account.

android.permission.WAKE_LOCK – client app

can keep the processor from sleeping when a message is received.

applicationPackage.permission.

C2D_MESSAGE – prevents other apps from

registering and receiving the GCM message.

For a better understanding it is necessary to pay attention to receive permission. Because, if client app

uses an IntentService (class for Services that

handle asynchronous requests on demand), broadcast receiver should be an instance of

WakefulBroadcastReceiver (creates and manages

partial wake lock on client app). A Service (typically an

IntentService) to which the

WakefulBroadcastReceiver passes the work of

handling the GCM message, while ensuring that the device does not go back to sleep in the process codes like this (Android Developers, 2014b):

Page 52: Case Mobile

122 CASEmobile

<receiver

android:name=".GcmReceiver"

android:permission="com.google.android.

c2dm.permission.SEND"

>

<intent-filter>

<action android:name="com.google.

android.c2dm.intent.RECEIVE" />

<category android:name="com.

case26.gcmdemo" />

</intent-filter>

</receiver>

<service android:name=

".GcmIntentService" />

Code 1 – Enabling send messages

Broadcast receiver performs operations automatically when service starts with operations. The following code

snippet starts GcmService with the method

startWakefulService()inside the

GcmReceiver class:

// Explicitly specify that GcmService

will handle the intent.

ComponentName comp=new

ComponentName(context.getPackageName()

,GcmService.class.getName());

// Start the service, keeping the device

awake while it is launching.

startWakefulService(context,

(intent.setComponent(comp)));

setResultCode(Activity.RESULT_OK);

Code 2 – Starting GCM Service

Client app cannot receive messages before it is registered with the GCM servers. To achieve this, developers must use class that extends the

GoogleCloudMessaging class with AsyncTask

object so receiving process can be performed in the

background. AsyncTask class enables easy use of

the UI thread and performing background operations.

Usually, registration should occur in the onCreate()

method in main activity or using a dialog if we want to give the user a choice about receiving GCM messages. It is necessary to include values of variables

Sender_ID and Application_ID given by Google

Developers Console. Once the registration ID is retrieved it is stored locally on the device

(SharedPreferences) and sent to 3rd

party server. It

is recommended to use HTTP connection so developers can have an immediate answer if the registration went well or not. The following code snippet shows short registration process, described previously:

if(gcm == null){

gcm=GoogleCloudMessaging.

getInstance(context);

}

regID=gcm.register(Globals.

GCM_SENDER_ID);

// Send the registration ID to 3rd part

server server via HTTP

sendRegistrationIdToBackend();

// PersisttheregID – no need to

registeragain

storeRegistrationId(context, regid);

Code 3 – Registers the app with GCM server asynchronously

If the registration went well with no errors as the feedback of Figure 4 on the screen of demo application will be show the following:

Figure 4 – retrieved Register ID

Based on the obtained Register ID, client app can also send messages to 3

rd party application server over

GCM server. The content of the message depends on what the developer wants to get out of the user's activities. It is important to point out that the GCM message is a JSON object containing some required and optional fields. There are several different formats depending on the direction in which communication goes:

Request format - from a 3rd-party app server or client app to CCS.

Response format – from CCS to 3rd-party app server (including ACK and NACK message formats).

For each device message that the 3rd-party application server receives from CCS it needs to send an ACK message. 3rd-party application server never sends a NACK message. CCS sends an ACK or NACK for each server-to-device message, if client app doesn’t send an ACK for a message; CCS will just resend it again. The following code snippet shows how request format of JSON massage should look like:

"to":"REGISTRATION_ID",

"message_id":"m-453443534546",

"data":

{

"message":"case26",

"action":"com.case26.gcmdemo.ECHO",

}

"time_to_live":"500",

"delay_while_idle": false

Code 4 – JSON massage, Request format

We could get specified format with following code snippet which is written in java GcmActivity class:

newAsyncTask(){

@Override

protectedStringdoInBackground

(Void...params){

String msg = "";

try{

Bundle data = newBundle();

data.putString("my_message",

"case26");

data.putString("my_action",

Page 53: Case Mobile

CASEmobile 123

com.case26.gcmdemo.ECHO ");

String id =Integer.toString

(msgId.incrementAndGet());

gcm.send(SENDER_ID +"@gcm.

googleapis.com", id, data);

msg="Sent message"; }catch

(IOException ex){

msg="Error :"+ex.getMessage();

}

return msg;

}

}

Code 5 – Upstream a GCM message up to the 3rd party server

3.2 How to implement GCM Server

As mentioned previously, server side of GCM consists of Google-provided GCM Connection Servers (HTTP or CCS over XMPP) and 3

rd-party application server which

developer must implement. 3rd

-party server must be able to communicate with client and GCM Connection Servers with properly formatted requests and be able to respond incoming requests to it. It’s also important that each exchanged massage have a unique message ID that is located in the header of POST request. The first step that developer has to do is to make a decision which type of GCM connection server(s) to use. For a better understanding differences between two types of connection server(s) through the basic features are listed (Android Developers, 2014c):

Upstream/Downstream messages: HTTP: Downstream only: cloud-to-device CCS: Upstream and downstream (device-to-cloud, cloud-to-device)

Asynchronous messaging HTTP: 3

rd-party app servers send messages as

HTTP POST requests and wait for a response CCS: 3

rd-party app servers connect to Google

infrastructure using a persistent XMPP connection and send/receive messages to/from all their devices at full line speed.

JSON messages HTTP: sent as HTTP POST CCS: encapsulated in XMPP messages.

Before we go on with implementing GCM Server, it is important to pay attention to types of messages. Every message sent in GCM has payload limit of 4096 bytes and by default it is stored by GCM server for 4 weeks. There is two main types “send-to-sync” (collapsible message) and “message with payload” (non-collapsible message). Send-to-sync message tells a mobile device to sync data from server, where the most recent message is relevant. New message will replace the preceding message.

GCM message parameter collapse_key plays here

an important role because it’s used to collapse a group of similar messages when the device is offline. This means that only the most recent message gets sent to the client app. GCM allows a maximum of 4 different collapse keys to be used by GCM server at given time. More than four collapse keys could cause unpredictable consequences.

Messages with payload are delivered every time;

collapse_key is omitted; the payload the message

can be up to 4kb and after 100 stored messages, GCM will discard old messages. For demonstration purposes, we will not use our own 3-rd-party server

implementation, because we can use “Push Bot” services API for push messing described in next chapter. Push Bot can push notifications via XMPP to feeds that support server-to-server PuBSUBHubbub protocol. These Servers can get near-instant notifications when a topic they’re interested in is updated (PushBots, 2012). To use this API, in the Android project “Pushbots131beta.jar” library should be included. With this library, inside the onCreate(Bundle bundle) method, developers can implement push notification for mobile devices with a one single line of code:

Pushbots.init(this, “Sender_ID”,

“Pushbots_App_ID”);

Code 6 – PushBot function

When the message is sent using the GCM on the screen of android Mobile device, there will be the following content in the notification area:

Figure 5 – Message sent to device via 3rd party

application server

3.3 User notification

User notification is feature that enables 3rd

-pary app server to send a single or multiple messages to client apps and app instance that a user owns to reflect the latest messaging state. The way this works is that during registration, the 3-rd party server requests a notification key which is used as an address to send messages (Android Developers, 2014a). The notification key maps a particular use to all of the user’s associated registration IDs, allowing him to send message to all of the user’s regIDs. To create a user notification key, a JSON request must be sent to GCM Notification endpoint. The notification key for a user’s device is only stored on the server. This feature can be used with either the XMPP or HTTP connection server. The Figure shows how communication works with CCS console:

Figure 6 – GCM User Notification using CCS (Cambell, 2013)

Page 54: Case Mobile

124 CASEmobile

To use these feature developers can perform generate/add/remove operations, and send upstream messages. To send a message, the application server issues a POST request to URL https://android.googleapis.com/gcm/notifi

cation. And the following JSON format will be used:

//header, project ID API key for

authentication

content-type: "application/json"

Header : "project_id": <projectID>

Header: "Authorization", "key=API_KEY"

Request:

{

“operation”:[“create”,”add”,”remove”],

“notification_key_name”:”user1_hash”,

“registration_ids”:[“XYZ”, “ABC”]

}

Code 7 – Request Format to work with notification key operations

Here is a code example that shows targeting a notification key for sending the message, which Bundle data consists of a key/value pair:

GoogleCloudMessaging gcm =

GoogleCloudMessaging.get(context);

String to = NOTIFICATION_KEY;

AtomicInteger msgId = new

AtomicInteger();

Bundle data = new Bundle();

data.putString(„26", „case26“);

gcm.send(to, id.toString(), data);

Code 8 – Upstream messaging

4. VULNERABILITIES AND THREADS

Last year at the end of July, Kaspersky Lab, computer Security Company, has announced that they have found a backdoor in GCM service. Backdoor is defined as method of bypassing normal access to a program, online service or entire computer system, securing illegal remote access to a computer, while attempting to remain undetected. In our case, the backdoor can be used by criminals to send SMS messages to premium-rate numbers, for stealing data from Android devices and also to send messages which content includes links to itself or other malware. Previously mentioned, messages are sent in JSON format what enables hackers to take advantage for malicious purposes. Once gained a GCM ID, malware updates are distributed exploiting directly the GCM services. Also the Command to the malicious agent is sent is by exploiting the service and using JSON format. Using GCM as Command and Control server for Android Malware is already generally

known concept. The top three most Android Trojans that used JSON format are listed below:

SMS.AndroidOS.OpFake.bo SMS.AndroidOS.FakeInst.a SMS.AndroidOS.OpFake.a

“Trojan-SMS.AndroidOS.OfFake.bo is one of the most sophisticated SMS Trojans. Its distinguishing features are a well-designed interface and the greed of its developers. When launched, it steals money from the mobile device’s owner – from $9 to the entire amount in the user’s account. There is also the risk of the user’s telephone number being discredited, since the Trojan can collect numbers from the contact list and send SMS messages to all of those numbers. The malware targets primarily Russian-speakers and users in CIS countries.” (Chebyshev and Unuchek, 2013)

Kaspersky Lab has reported Google about the discovered vulnerabilities, and announced that the only way to protect users against such attacks is through blocking developers’ accounts with IDs linked to the registration of malicious applications. The number of malware that exploits the GCM service is relatively low. Most malware are prevalent in Western Europe (particularly in Russia) and Asia.

5. CONLUSION

This paper briefly introduced Google Cloud Messaging for Android (GCM) which is defined as service that allows developers to send data from 3

rd party server to

their users' Android-powered devices, and also to receive messages from devices on the same connection. The GCM service handles all aspects of queuing and delivery to the target Android application. Key concepts of GCM are the components which make the architecture of GCM and the credentials used for access authentication in different stages of GCM. Components include client app that runs on Android device, 3

rd-party app server and GCM connection

server. Credentials are the IDs and tokens used in different stages of GCM (Sender ID, application ID, registration ID, google user account and sender auth token). GCM has many useful features such as: “Send to Sync” and “Send data” capabilities, support for multicast messages, delay while idle, and the use of persistent connections (by using XMPP), the upstream messaging and synchronization notification across multiple android devices etc. The new CCS API for GCM messages has made sending messages faster than the HTTP API, but with the added complexity of an asynchronous process. GCM is a great way for Android developers to manage the communication with their applications and users, but it also has important disadvantages that should be taken in consideration.

References:

1 Android Developers, 2014a. GCM Overview [WWW Document]. Google Cloud Messaging - Overview. URL http://developer.android.com/google/gcm/gcm.html (accessed 5.9.14).

2 Android Developers, 2014b. Implementing GCM Client [WWW Document]. Implementing GCM Client. URL http://developer.android.com/google/gcm/client.html (accessed 5.9.14).

3 Android Developers, 2014c. Implementing GCM Server [WWW Document]. Implementing GCM Server. URL http://developer.android.com/google/gcm/server.html#choose (accessed 5.12.14).

4 Cambell, A., 2013. Google Cloud Messaging: Cloud Connection Server Tutorial [WWW Document]. CapTech consulting. URL http://captechconsulting.com/blog/antoine-campbell/google-cloud-messaging-cloud-connection-server-tutorial (accessed 5.9.14).

Page 55: Case Mobile

CASEmobile 125

5 Chebyshev, V., Unuchek, R., 2013. Mobile Malware Evolution: 2013 - Securelist [WWW Document]. URL http://www.securelist.com/en/analysis/204792326/Mobile_Malware_Evolution_2013?print_mode=1 (accessed 5.19.14).

6 freelancersnepal, 2014. Google Cloud Messaging (GCM) in Android using PHP Server. Freelancersnepal.

7 Google Developers, 2013. Google I/O 2013 [WWW Document]. Google I/O 2013. URL https://developers.google.com/events/io/ (accessed 5.26.14).

8 HMKCode, 2014. Android Google Cloud Messaging Tutorial. Android Google Cloud Messaging Tutorial.

9 PushBots, 2012. PushBots: communicate with your mobile app users in minutes [WWW Document]. PushBots. URL https://pushbots.com (accessed 5.26.14).

Information on authors:

Zoran Kos B.Sc

e-mail: [email protected]

Zoran Kos is 2nd

year student of Information and Programming engineering of Faculty of Organization and Informatics in Varaždin. Main interests are programming web, desktop and mobile application, new IT trends like cloud computing and mobility, making and presenting business models for startup projects. While developing new apps he focused on front-end development. He already has few smaller but successful projects behind him.

Zoran is the main contributor to this paper. He wrote the first version of the text and did coding of the presented examples.

Zlatko Stapić, PhD.

e-mail: [email protected]

Faculty of Organization and Informatics

Pavlinska 2, 42000 Varaždin, Tel: +385 42 390 820, Fax: +385 42 213 413

Zlatko Stapić, PhD., works at the Information Systems Development Department at Faculty of Organization and Informatics in Varaždin. He obtained his PhD in computer sciences from University of Alcalá (Spain) and in information sciences from University of Zagreb (Croatia) in cotutelled doctorate program. His scientific and research interests include software- and mobile applications development methodologies. He participated in more than 15 scientific and professional projects and published more than 30 scientific and professional papers. Currently he leads the Laboratory for Development and Transfer of Mobile Technologies (FOI MT-Lab). Zlatko is putting a special focus in inclusion of students in his scientific and professional activities. The published papers, projects, awards and other relevant information can be found on his personal website: http://www.foi.unizg.hr/djelatnici/zlatko.stapic.

Zlatko’s contributions to this paper are only of corrective nature. He mentored student Zoran Kos in defining the body, the structure and the style of the paper. After the first version of the paper is written, he proof-read the text and made necessary changes to make the text more focused and readable.