Knowledge7

The Linux and Mobile Solution Provider

  • About
  • Training
  • Services
  • Clients
  • In the news
  • Blog
  • Contact Us
You are here: Home / Blog

Handling mobile events

This topic is part of our Mobile Application Development with HTML5 training

jQuery Mobile has a number of hooks to handle events such as taps, swipes, etc. In addition to those, the framework also provides more general events such as pageinit and pagebeforeload which allow code to be executed at specific instants in the lifecycle of a page. Finally, there are also a number of methods which can be used to change the behaviour of the web application when specific events occur.

The work to do is:

  • Change the Javascript code already written to be more jQuery Mobile compliant
  • Add a handler for swipeleft on the four songs pages
  • Add a tap handler on the names of the French songs to display a dialog
This topic is part of our Mobile Application Development with HTML5 training

Our forthcoming training courses

  • No training courses are scheduled.

jQuery Mobile for HTML5-based user interfaces

Mobile Application Development with HTML5

Our next Mobile Application Development with HTML5 training starts on 11 February 2015.
This course has been designed for people who wish to develop mobile applications which will run on different platforms. Using latest technologies and features of HTML5 and Javascript, you will build mobile applications which feel and behave mostly like native applications.

Call us on 5834-9001 to book your seat or to get free advice.

There is a lot of debate among mobile developers about whether to go native when building mobile apps or to use HTML5. The latter is particular attractive as the single codebase approach – write once, run everywhere – often implies reduced development costs. Developers can use their existing HTML5/CSS3/JS skills to build applications which can be repackaged easily for different platforms – iOS, Android and others – using tools such as PhoneGap/Cordova. These tools also have a set of plugins which allows developers to use hardware features such as battery, camera and GPS among others.

On the otherhand, a major advantage of native apps is that they are more visually appealing and offer a better user experience when compared to the interface of a cross-platform application build with HTML5.

But is there a way around? I think so.

jQuery Mobile is a framework for developing HTML5-based user interfaces for smartphones and tablets. As it is multi-platform, web applications built with jQuery Mobile, look and feel the same whether one is using Android or IOS devices. The framework also supports Blackberry, Windows Phone, Symbian, etc.

https://www.youtube.com/watch?v=tXRuotrRUfc

This is the framework that trainees are going to use, together with Cordova, during our next Mobile Application Development in HTML5 training. For some time I was wondering whether it would have been better to write all HTML5 code “manually” and, finally, I realised that jQuery Mobile saves a lot of time and has a formidable set of widgets and behaviours which would be difficult to replicate “manually”.

Anyone of you using jQuery Mobile at this moment? What do you think of it?

Our forthcoming training courses

  • No training courses are scheduled.

Picks of the Week #8

You want to receive our Picks of the Week every Monday morning?

Merry Christmas! Thank you for reading the eight edition of Knowledge7’s Picks of the Week on this special day!

Every two weeks, Avinash Meetoo and his team of collaborators will make you discover interesting articles and websites to help you broaden your understanding of the world of open source software and information technology in general.


Recess Framework
Want to build a highly scalable RESTFul archirecture in PHP ? Choose Recess! By Chris Jordan, CEO of New Media Creations. Recess aims at developer joy, whether you are a beginner or a professional, Recess! puts you on the right track to bring life to your server. Running on PHP 5.3, Recess! gives you proper tools to quickly and efficiently build a REST API. Based on the MVC structure, Recess! puts at your fingertips cool developer tools ranging from tools for model,controller and view creating, code introspection and an application route summary that run as a bundled browser app. If ever after using Hibernate in Java, you have been crazy looking a similar one in PHP, then Recess! has a really nice looking ORM that automate a very important aspect, Lazy Loading. Besides being well documented and having a large community, there are many upcomming developments which include plugin system, model validation and an improved templating system for the views. Also, setting it on your server is free from crazy configurations, just download it, place it on your server, set up your database and start creating great apps in Recess!

Google Web Toolkit
GWT, released by Google, is an open source software intented for the creation of Rich Internet Applications. You program in Java and through GWT Compiler, everything is converted to JavaScript. What’s really nice with this software is that while programming in Java, Web Programmers have a wide subset of the Java Libraries with which lots of magic can be done. Moreoever, even if GWT uses Java, its also allows support to wrap JavaScript within Java through JSNI (JavaScript Native Interface). Many other frameworks on the market force a pattern but GWT gives you the freedom to structure your app with any pattern, whether with MVP or MVC or any other. Also, in many cases, Web Programmers have to be browser gurus in the sense they have to understand browsers’ tradeoffs and incompatibilities and implement workarounds. However, with GWT, the compiler handles heterogenous browser platforms by generating several versions of the JavaScript intended for numerous browser engines such as gecko, safari and many others. Well, Web Programmers, what are you waiting for, rush to GWT and start building powerful Rich Internet Applications that gonna surprise web surfers.

HTML Purifier
You want to save HTML from your clients, then bear in mind, not all client are ‘good’, some are really ‘bad’. ‘Bad’ Clients can insert malicious code within the HTML and then perform things that surely you wouldn’t be happy to know. However, to prevent these problems, HTML Purifier is here to parse your HTML from malicious content such as xss. Attackers can place series of xss within HTML. What HTML Purifier really does is that it tokenises the whole HTML content and defeats xss by removing all non-whitelisted elements. Morever, it cleans the HTML through ensuring that HTML contents are well-formed by validating all attributes according to their RFCS. Thus, aftet using HTML Purifier, your document is both safe from malicious code and also W3C compliant. In case , you are using some frameworks, then you are lucky enough because HTML Purifier Plugins are available for some major frameworks such as Drupal, WordPress, Joomla, Symphony and others.

Jahshaka
Formely CineFX, Jahshaka is a video editing software written in QT and uses OpenGL and OpenML. It provides solution for film compositing, editing and special fx system that uses OpenGL and OpenML hardware rendering to give operators real time interactivity. Edit your videos in an easy and flexible way, create effects in real time, animate, paint, add texts, support for many video formats, etc. – these are just a few of key features of this advanced video editor.The program is available for multiple platforms including Linux, Mac OS X and Microsoft Windows. Currently, the official page of Jahshaka shows a countdown to the release of Jahshaka 3.0. But if you are pretty impatient about it like me, you can try out Jashaka 2.0 from here.

JQuery UI
Want to build highly interactive web applications, try JQuery UI. Jquery UI is a widget and interaction library built on top of JQuery JavaScript Library. Jquery UI provides a comprehensive set of core intareaction plugins, UI widgets and visual effects that use a jQuery-style, event-driven architecture and a focus on web standards, accessiblity, flexible styling, and user-friendly design. On top of that, Jquery UI has its own powerful theme framework with a wide theme gallery that also allows you to create your custom theme. With interactions such as Draggable, Droppable and widgets like Accordion and Tabs and amazing Utilities and awsome effects, you can know build great Web Applications that are compliants with major browers such as IE, Firefox, Safari, Opera and Chrome.

The picks for this week have been selected by Noor Bakerally, Research & Development Specialist at Knowledge7.

Our forthcoming training courses

  • No training courses are scheduled.

Announcing AndroidMauritius and Knowledge7 forum

Knowledge7 is proud to announce the launching of a new Android portal at androidmauritius.com. During the past 18 months, Android use has exploded around the world and in Mauritius to become the world’s most widely-used operating system for smartphones and tablets. Google has just announced that people have downloaded Android applications more than 10 billion times hence showing how dynamic the Android ecosystem is.

AndroidMauritius provides the latest news concerning Android, reviews Android smartphones and tablets available in Mauritius, and gives tips and tricks.

[img_assist|nid=411|title=|desc=|link=url|url=http://www.androidmauritius.com/|align=center|width=454|height=342]

Remaining faithful to Knowledge7’s motto ‘Sharing Expertise’, we are also glad to announce the launching of our new forum at knowledge7.com/forum. Open-source enthusiasts and IT professionnals will be able to discuss and share their knowledge on the various open-source software and technologies they use on a daily basis such as Linux, PHP/MySQL, Java. Android, etc.

[img_assist|nid=412|title=|desc=|link=url|url=https://www.knowledge7.com/forum/|align=center|width=454|height=277]

We hope that you will find both AndroidMauritius and the Knowledge7 forum useful. Feel free to share with your friends and colleagues.

Our forthcoming training courses

  • No training courses are scheduled.

Services and Notifications

This topic is part of our Android Application Development training

Some Android application depend on data available on the Web. For example, a TopTracks application might show the top 10 tracks of a given artist using a web service such as AudioScrobbler.

Downloading this data can be slow and it is preferable to use a service to do that. In this way, the “main screen” of the application is an Activity and only takes care of displaying the user interface and starting / stopping the download service.

The application to develop allows the user to enter the name of an artist:

Click on Show Tracks does not necessarily display the tracks as this requires the track information to be downloaded first. This is done by clicking on Start Service.

When the data has been downloaded, the service displays a notification in the status bar telling the user that the top tracks have been downloaded. It is only then that the user can click on Show Tracks to get:

This topic is part of our Android Application Development training

Our forthcoming training courses

  • No training courses are scheduled.

More widgets

This topic is part of our Android Application Development training

One important Android widget is AutoCompleteTextView which, as its name indicate, is a text view which allows the user to select text from among a list of possibilities based on the initial text typed:

As shown above, the user types “Ven” and is shown Venus on which the user can click on.

A second useful widget is the SeekBar which allows the user to select one value by dragging (here, a font size):

Finally, it is possible to embed a web browser within any Android application using a WebView. Note that this is different from launching a web browser activity (which launches the native Android web browser):

This topic is part of our Android Application Development training

Our forthcoming training courses

  • No training courses are scheduled.

Preferences, File System and Menus

This topic is part of our Android Application Development training

The work to do is to add a menu (also called an options menu) to the PermutationsReloaded application as shown in the picture. Choosing clear will erase everything on screen while choosing about will display a pop-up with some information about the app.

To create the menu, one should build one using the appropriate XML editor and override the onCreateOptionsMenu method of the activity. To handle clicks, the onOptionsItemSelected method will also need to be overriden.

Context menu

The second step is to add a context menu which opens when one long-presses on any of the permutations. The choices shown are “To uppercase” and “To lowercase” which are explicit enough.

The methods which are important here are onCreateContextMenu and onContextItemSelected as well as registerForContextMenu and unregisterForContextMenu.

Something noteworthy is that onCreateContextMenu is executed each time a context menu is shown (and not only once) and that one of its parameters is the view on which the long-press has been done.

Managing Preferences

The last enhancement to bring to the application is to allow the user to specify whether the last word entered should be remembered. If yes, the next time the application is started, the word should already appear in the EditText and the permutations shown.

To do that, a preference screen should be created using the XML editor, then a class derived from PreferenceActivity should be created and the onCreate method overriden. This new activity should be manually added to AndroidManifest.xml.

When this activity is launched (using, for example, startActivity), the Android framework will automatically store the preferences.

Finally, the application will have to be updated to store the word entered if the user has chosen to do so as well as restore that word when the application is resumed. The way to do that is to get a SharedPreference object from the PreferenceManager.

Accessing Files

Android applications can access files residing at three distinct places:

  • Found in the application APK itself. This file is read-only as it is considered to be one of the static resources of the application. The work to do is to develop an application called Anagrams which given a word shows all the various anagrams of that word. Of course, this requires a dictionary and it will be stored in the APK. The key method to use here is openRawResource to get access to that dictionary.
  • Found in flash memory. The second version of the application provides a simple menu (with load / save) which, depending on the item selected, either load or saves the anagrams found. This second version of the application loads and saves from flash memory.
  • Found on the SD card. The third version of the application read and writes data on the SD card instead of using flash memory.
This topic is part of our Android Application Development training

Our forthcoming training courses

  • No training courses are scheduled.

Knowledge7 sponsors Terre de Paix

For our first Corporate Social Responsibility contribution, we have decided to sponsor Fondation Pour L’Enfance – Terre de Paix. This NGO aims at combating poverty in general and has among its objectives to carry out child care activities in a secular and non-discriminatory way.

On June 30, the chairman of Knowledge7, Mr Jaynarain Meetoo, presented a cheque to Mr Alain Muneean, the secretary of Terre de Paix and Mrs Patricia Yue to encourage them in their efforts to make a better world for children.

Why did we choose this NGO? Simply because Knowledge7 strongly believes that education is the key to the success of our future generations.

Our forthcoming training courses

  • No training courses are scheduled.

A Quick Start

This topic is part of our Android Application Development training

Android applications generally have four types of components:

  • An activity represents a single screen with a user interface. An application can have multiple independent activities.
  • A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. For example, a service might play music in the background while the user is in a different application.
  • A content provider manages shared application data. Other applications can query or even modify the data through the content provider.
  • A broadcast receiver is a component that responds to system-wide broadcast announcements. A typical broadcast receiver might initiate a service to perform some work based on the event.

It is important to understand that any application can start another application’s component… but only indirectly as Android runs each application in a separate process. To do that, the application must deliver a message to the system that specifies its intent to start a particular component in a different application. The system then activates that component.

Work to do

Let’s start quickly. The first step is to setup the development environment as explained in the previous topic: (Java, Eclipse, Android SDK and Platform Tools).

At this point, it is possible to create an Android Virtual Device (AVD) and run an emulator.

The next step is to launch Eclipse, install (if needed) and configure the Android Development Tools plugin and start developing Android applications!

HelloWorld

The first application to develop is HelloWorld which should simply display a nice message in an activity when launched. The content of HelloWorld should be explored (AndroidManifest.xml, bin/, libs/, res/, src/, assets/, gen/ and proguard.cfg) and understood. HelloWorld should be launched in an Android emulator to check whether it’s working correctly. It is also interesting to launch it on a real Android devices (because we can) 🙂

Now

The second application to develop is called Now. It displays one button which fills in the whole of its activity. When the button is clicked, the current date and time will be updated in the button’s label.

The way to do that is to add an Android button to the activity, setOnClickListener appropriately (i.e. to update the label to the current date and time). The easiest way to do that is to use a Java inner class at this point.

The AndroidManifest.xml generated by Eclipse contains an activity, an intent-filter whose purpose is to make the activity appear in the launcher and, very importantly, specifies a minSdkVersion (which is an integer corresponding to a specific version of Android) and, optionally, a targetSdkVersion:

  • 1 = Android 1.0 (obsolete)
  • 2 = Android 1.1 (obsolete)
  • 3 = Android 1.5
  • 4 = Android 1.6 (obsolete)
  • 5 = Android 2.0 (obsolete)
  • 6 = Android 2.0.1 (obsolete)
  • 7 = Android 2.1
  • 8 = Android 2.2
  • 9 = Android 2.3-2.3.2 (obsolete)
  • 10 = Android 2.3.3-2.3.7
  • 11 = Android 3.0
  • 12 = Android 3.1
  • 13 = Android 3.2
  • 14 = Android 4.0-4.0.2
  • 15 = Android 4.0.3-4.0.4

NowReloaded

The next application to be developed is an enhanced version of Now which, instead of using Java code to create a button uses an XML-layout generated graphically by the ADT plugin in Eclipse.

The Java code needs to be modified to use findViewById and care must be taken to really understand the difference between wrap_content and fill_parent (renamed to match_parent as from API level 8).

Forex

The next application is called Forex and allows the user to enter an amount in USD and, when the convert button is clicked, the MUR amount is calculated and displayed.

Airplanes

The application to build displays different airplanes based on which of the three radio buttons has been clicked on. The essential aspect of this application is that the radio buttons are found within a RadioGroup.

This topic is part of our Android Application Development training

Our forthcoming training courses

  • No training courses are scheduled.

Enter the Android Market with our brand new training

Android, developed by Google, is now the top-selling smartphone platform powering more than 100 million devices in the world. Android smartphones (and, now, tablets) are made by companies such as HTC, Samsung, Sony-Ericsson, Motorola, LG, Acer, Archos, Dell, ViewSonic and Toshiba. Fortune Magazine observes that Android powers 35% of the smartphones sold in the US in 2011 while Apple has 18%, Blackberry 14% and Microsoft 2% of the market share.

Applications can be easily added to Android smartphones and tablets by downloading them from the Android Market which hosts more than 240,000 free and paid applications which have already been downloaded more than one billion times.

Clearly, Android is massive and the market for Android applications is ever increasing.

Developing applications for the Android platform

The Android platform is open source software and the tools which are required to develop Android applications are readily available. Interestingly, Android applications are written in Java using a subset of the Java standard classes as well as Android specific classes. Someone willing to master Android apps development needs to be knowledgeable in object-oriented programming with Java.

At Knowledge7, we are proud to launch our new Android Application Development training starting on Wednesday 14 September and will run over five consecutive Wednesdays.

Over the duration of the training, participants will develop Android applications in our state of the art computer lab and test the applications on real Android devices. We will cover the following topics during the training: the user interface preferences, file system and menus, services, accessing databases, lists and adapters, broadcast receivers, content providers and system services (e.g. alarms, GPS and various sensors).

At the end of the training, the participants will know how to develop powerful Android applications ready to be submitted to the Android Market.

The trainer will be Avinash Meetoo, Founder and Managing-Director of Knowledge7. He has extensive experience of object-oriented programming, Java and Android development. During the last world cup, Avinash created an Android application, World Cup 2010 TV Guide, which was downloaded more than 15,000 times by people all over the world.

Do not hesitate to contact us on 5834-9001 for more details.

Our forthcoming training courses

  • No training courses are scheduled.
« Previous Page
Next Page »

Looking for something?

Want to know more?

Get our newsletter

Discover the latest news, tips and tricks on Linux, the Web and Mobile technologies every week for FREE

This work is licensed by Knowledge7 under an Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.