Showing posts with label News. Show all posts
Showing posts with label News. Show all posts

Wednesday, February 16, 2011

Porting Android (Java) applications to Qt for Symbian


As an initiative of  The Open Handset Alliance and Google, Android has been developed as the first open and free platform for mobile phones. The project has been developed since November 5, 2007, when Google Inc., Intel, T-Mobile, Sprint, HTC, Qualcomm and Motorola decided to achieve an ambitious goal: provide services so consumers would face a far better user experience.
An important point of the Android platform is that handset manufacturers and wireless operators can provide suitable versions of Android for their products and services. This characteristic directly impacts on lower cost and innovative products. Therefore, Android can be considered a new and potential option for mobile platforms for smartphones.

On the other hand, Qt has been considered a powerful component in this newest mobile programming arena. Qt is most notably used in Desktop applications, such as KDE, Opera, Skype and VirtualBox, but recently it has been ported to Nokia mobile platforms, such as S60 and Maemo. Initially developed by Trolltech since 1991, Qt is released with two different licenses (open source and commercial), which should make Qt more suitable for non-GPL open source projects and for commercial users. In June 2008, Nokia acquired Trolltech to enable the acceleration of cross-platform software strategy for mobile devices and desktop applications. On September 29, 2008 Nokia renamed Trolltech to Qt.
This article provides information that guides development to port Android applications to Qt for Symbian.

Overview of Android Platform

Android applications are developed with the Java programming language (Dalvik virtual machine), and device services, such as touchscreen and storage features, can be accessed through the Google services API. It is possible to run applications written in C or any other language, but the applications have to be compiled to native code and run; this development path is not officially supported by Google.
Since October 2008, Android has been available as an open source project (Apache License). Handset manufacturers and wireless operators are free do add closed and proprietary extensions to their products.
Although Android is based on a Linux kernel, according to Google, it is not a Linux operating system. In addition, it does not have a native windowing system, nor does it support the full set of standard Linux libraries, including the GNU C Library. This characteristic make it difficult to reuse existing Linux applications or libraries. Android does not use standard Java APIs, such as J2SE and J2ME. This prevents compatibility between Java applications written for those platforms and those for the Android platform. Android only reuses the Java language syntax, but does not provide the full-class libraries and APIs bundled with J2SE or J2ME.
The next picture shows the current Android architecture (from the Android Developer's Guide).

The system has access to mobile phone resources through system drivers, such as camera, display, WiFi and keypad drivers. Then, the next layer consists of libraries and the runtime system of Android. Finally, Android provides a set of libraries (Application Framework) so it is possible to extend them and create new applications.
Android makes it possible to reuse components of other applications. For example, if you need to reuse a component that provides a suitable scroller and made it available to others, you can invoke such a component to do the work for you. Therefore, the system has been designed to start an application process when any part of it is needed, and instantiate the Java objects for that part. Therefore, Android does not provide an entry point, such as main function, but essential components: activity, services, broadcast receives and content providers.
Activities represent screens on an Android application. From an activity, you can display buttons, labels, menus and much more. All activities subclass the android.app.Activity class. Services do not have visual appearance, but they run in the background. For example, a service may play music while the user performs other tasks. Each service extends the android.app.Service base class. Broadcast receives are components that receive and react to different broadcast announcements, for example, a message that the battery is low. All receivers extend the android.content.BroadcastReceive base class. A content provider is responsible for making an application's data available to other applications. Therefore with content providers, it is possible to share data between different applications. All content providers extend the android.content.ContentProvider base class.
The Android development environment consists of: the Android SDK, Android source code and, optionally, IDEs that help make programming Android applications a lot quicker. The Android software development kit (SDK) consists of libraries and tools, including an emulator to run applications. The Android SDK is available for Windows, Mac OS X, and Linux. There are different IDEs that provide support for Android development, such as Eclipse (with the Eclipse plug-in for Android).

Overview of Qt for Symbian 

Qt applications are developed with C++ enhanced with additional extensions implemented by a pre-processor that generates standard C++ code before compilation. Qt also provides bindings for several other programming languages, like Python, Ruby and Perl.

Qt is notably used because of its GUI widgets, but also provides a set of non-GUI related features: SQL database access, XML parsing, thread management, network support and a unified cross-platform API for file handling. Qt has been successfully ported to the Nokia Symbian S60, Maemo, and MeeGo platforms. Qt for Symbian will “enable you to create advanced applications with innovative user experiences while getting to market quickly”. Compared with Android, Qt is an interesting and easy-to-use programming framework that certainly brings a considerable contribution to mobile programming as well as desktop application development.

Qt Mobility has been completely ported to Symbian, and commonly used mobile features are accessible through the Qt Mobility APIs such as camera, geolocation, and contacts APIs. There are rapid on-going progress of making all mobile features accessible, and some features which are not provided by Qt Mobility APIs can still be accessed through native Symbian APIs.
In order to develop Qt Symbian applications, you simply need to install the Nokia Qt SDK, which contains Qt SDK, Qt Mobility SDK, Qt Creator, Qt Simulator for Symbian and N900, and libraries, tools (including the emulator for S60 environment), and all documentation you need to get started.
Qt Creator is an IDE built on Qt itself, and contains an easy-to-use visual designer for designing your application UI. An alternative to Qt Creator is Carbide++ IDE (based on the Eclipse framework). Both Qt Creator and Carbide C++ IDE provide a fully featured environment that helps a lot with development. You can find interesting articles on the Forum Nokia Wiki covering Qt for Symbian (see Category Qt for Symbian).
Qt for Symbian applications are easily built with Qt Creator (included in Nokia Qt SDK) or Carbide IDE and they can be launched on the Qt Simulator, Symbian S60 emulator, or even on your device (you have to install Qt for Symbian libraries first, however a properly packaged Qt for Symbian application can do this automatically via Nokia Smart Installer). The entry point of any Qt application is the main method (remember that Android applications start from an Activity instance).

Examples 

This is a simple “Hello World” application on Android.

package helloandroid;
 
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
 
public class HelloAndroid extends Activity {
 
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText("Hello World");
       setContentView(tv);
   }
}
As explained before, the entry point of any Android application is an Activity (more strictly, the method android.app.Activity#onCreate(Bundle)). There's no label class on Android, but text views can be also used as labels. Then, we create a text view and we set the contents of Activity with the text view that was just created.
Now, let's see the same application, but on the Qt framework.
#include <QApplication>
#include <QLabel>
 
int main(int argc, char *argv[])
{
  QApplication app(argc, argv);
  QLabel label("Hello, world!");
  label.show();
  return app.exec();
}
It simply opens an application and shows a label with the “Hello World” string. You can check that the main Qt class (QApplication) is properly initialized with the given main method arguments. As described before, the entry point for Qt applications is the main function of your Qt main class. Then, it creates a simple label and shows its content. Finally, the application returns the code result from execution of the Qt application. Another important point is that such code can also be built and launched on the Maemo platform (obviously, the graphical result is different, since you're using a different platform with different widgets).
The following example shows how we can insert a menu with Android and Qt applications.
On Android, the menus are defined with the method android.app.Activity#onCreateOptionsMenu(Menu). The callbacks for menu items are defined with the method android.app.Activity#onOptionsItemSelected(MenuItem).
package helloandroid;
 
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Menu;
import android.widget.MenuItem;
 
public class HelloAndroid extends Activity {
 
   private final int MENU_QUIT = 1;
 
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText("Hello World");
       setContentView(tv);
   }
 
   /* Creates the menu items */
   public boolean onCreateOptionsMenu(Menu menu) {
       menu.add(0, MENU_QUIT, 0, "Quit");
       return true;
   }
 
   /* Handles item selections */
   public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_QUIT:
        quit();
        return true;
    }
    return false;
   }
 
}

On Qt for Symbian, it is a little bit easier :). You just need to define a QAction. Then, insert it onto the application menu bar. Finally, the callback is defined with the method connect (used to define any callback on Qt).

#include <QApplication>
#include <QAction>
 
int main(int argc, char *argv[])
{
  QApplication app(argc, argv);
  QAction exitAction = new QAction(tr("&Exit"),this);
 
  // Add action direct to menubar
  menuBar()->addAction(exitAction);
  connect(exitAction, SIGNAL(triggered()),this, SLOT(close()));
}

API Mappings


File I/O

  • To read from or write to files or other devices.
    • Android classes (from package java.io): File, FileReader, FileWriter, BufferedReader, BufferedWriter
    • Qt classes: QIODevice, QFile, QTemporaryFile, QBuffer, QProcess, QTcpSocket, QUdpSocket, QDataStream, QTextStream

Networking

  • Socket communication.
    • Android classes (from package java.net): Socket, InetSocketAddress, ServerSocket
    • Qt classes: QTcpSocket, QUdpSocket
  • HTTP/FTP communication.
    • Android classes (from package java.net): HttpURLConnection, URL
    • Qt classes: QNetworkAccessManager, QUrl, QUrlInfo
    • Android classes (from package org.apache.http.*): HttpClient, HttpGet, HttpPost, HttpResponse
    • Qt classes: QHttpHeader, QHttpRequestHeader, QHttpResponseHeader
    • Qt class: QFtp (no equivalent on Android)

Media

  • To read from or write to files or other devices.
    • Android classes (from package android.media): MediaPlayer, MediaRecorder
    • Qt classes: AudioOutput, MediaController, MediaNode, MediaObject, MediaSource, ObjectDescription, Path, VideoPlayer

Android vs Qt for Symbian

Android was designed as a platform for mobile phones. Therefore, it provides access to different system resources, such as touch screen, camera, and telephony. On the other hand, Qt is a cross-platform application and UI framework designed for Desktop and Mobile environments. Qt provides mechanism to access resources of the mobile phone through Qt Mobility APIs. The following list shows some important differences of Android and Qt for Symbian.
  • Android provides access to PIM (Contacts, Calendar), Qt Mobility provides the Contacts API and Organizer API and Versit API;
  • Android provides access to Telephony, Qt Mobility provides Bearer Management API;
  • Android provides access to Messaging, Qt Mobility provides the Messaging API;
  • Android provides access to Camera, Qt Mobility provides Multimedia API;
  • On Android, it is possible to load an application UI from an XML description file (Maemo also support this feature if you use Glade to build your application's UI). Qt for Symbian provides two ways to design your application UI: Form Designer in Qt Creator for designing application user interfaces, and QML of Qt Quick for fluid interaction with animations.
  • Android is based on Java and Qt for Symbian is based on C++;
  • Android applications are restricted to the Android platform, while Qt is cross-platform. A properly designed Qt application can be executed on Symbian, Maemo, and MeeGo mobile devices, and also on Windows, Linux, and Mac OS desktop platforms.

Resource : wiki.forum.nokia.com

Sunday, February 13, 2011

How Windows 8 will try to compete with Android and Mac OS X

 
What we know about Windows 8 is still incomplete and unofficial - garnered from job postings, rumours and the slides allegedly leaked by a software engineer at HP responsible for OEM relations (available through the Italian Windows Ette site).

The slides include plenty of marketing ideas rather than technical details, they show that Microsoft has its eye on what Apple is doing to make its operating systems so popular and they declare themselves a work in progress.

Not only is every page marked 'this is not a plan of record' but the opening discussion includes the line "reality: there are currently more ideas than there is time to implement them". That's especially true if Windows 8 release date is as soon as we think it might be.

Windows 8 release date

Windows 8, say the slides, will be available "for the holiday" - but not which one.

There's a timeline that doesn't have many dates; the one suggesting that the coding would begin in June is suspect when some sources say the M1 (milestone 1 build) is already done and there's what we assume is a typo that we'd correct to say the third Forum (rather than the second) would be in July (there are several points where the slides are incomplete or confusing; for instance a pointed reference to "creating great Dell + Windows Experiences" in a deck that otherwise tips the hat - and appears to have been intended for - HP).

It puts the first beta of IE9 in August, along with the shipping date for Windows Live wave 4 which fits other rumours and positions them just after the third Forum.

That makes the forums three-to five months apart; assuming an average of four months - and assuming the chart is to scale and that the dates don't slip - that puts Windows 8 beta release date a little before March 2011 and Windows 8 RTM shortly after July 2011 (a date suggested on the blog of a now-ex Microsoft employee which you can find preserved, with the boxed version following in the autumn - for the holiday).

We've said before that we expect Windows 8 in late 2011 or early 2012 and we don't expect Microsoft to talk about a date until the Milestone 3 build, which would be around November 2010 by these calculations.

The fact that Microsoft hasn't announced whether the Professional Developers conference (usually held in November and used to preview new versions of the OS) will happen this year makes this a little less likely and it could all be some months later.

There are several statistics (typical RAM, network connected TVs, mobile broadband penetration and 4G deployment) that talk about the specs that will be common - in 2012.

Interestingly, the timeline shows Windows Live Wave 5 with a short development cycle that finishes before Windows 8; that matches suggestions that Live will offer more cloud services for Windows 8.

Windows 8 tablets are coming
The leaked slides are aimed at PC manufacturers who are interested in new form factors - and in getting a share of the iPad market - so it's no surprise one of the key PC form factors is a 9" slate (which Microsoft, having obviously got the point of all those iPad ads, is calling a Lap PC), optimised for web and media, casual gaming, reading and sorting email, IM and social networking.
Microsoft promises big improvements to the on-screen keyboard: it will be "easily launched, text prediction is more accurate, the UI is more usable, and throughput is increased for everyone".
There's also the workhorse PC (which is also referred to as a laptop, because Microsoft is only talking about consumers and not business users) and the family hub (an all-in-one touchscreen system that can go in the kitchen or the living room as a media centre) which is for casual gaming, web and media as well as more demanding apps like organising and manipulating media.
Key to making a successful Windows tablet is apps with user interfaces that change depending on the form factor (touch and gestures instead of keyboard and mouse), but Microsoft is also looking at stereoscopic 3D and high colour displays and natural input that uses touch, voice, 3D gestures ("on the horizon"), and facial recognition.

Optimising "for smaller screens" will help netbook users as well; Windows 7 gets key dialog boxes to fit on a small screen but not all apps do.

Another app store
More than 30 app stores have launched in the last year and Microsoft isn't the only company copying Apple here; Intel has its own app store for Atom PCs. PC makers like the idea - apparently at the first forum they commented that it "can't happen soon enough".
With an app store, Microsoft hopes to attract more of the type of developers who are currently building smartphone apps and it wants them to create apps that make Windows the best place to use web apps (a job advert last October claimed "we will blend the best of the web and the rich client by creating a new model for modern web applications to rock on Windows".)
According to the slides, "Currently the indication is that app development will move to the Web. There is significant opportunity for Microsoft if hardware capabilities, and OS services and Web could be integrated into a hobbyist developer toolset."
The 'tailored experiences' Microsoft talks about for Windows 8 sound like smartphone apps; the checklist includes fast installation and updates for engaging, social, extensible, ad-supported or 'freemium' apps.
If smartphone-style apps sound too simple to be worthwhile on Windows, Microsoft wants apps to be extensible so you can share information between them - perhaps using a mix of simple apps together. It sounds like the 'mashups' that we were all going to be making online until it turned out you'd have to learn to program.
The Windows Store will be branded and optimised for each PC manufacturer. Your settings will follow you from PC to PC, as will your apps (although some slides refer to this as a possibility rather than a definite plan) - but you'd need an HP ID to log into the 'HP Store powered by Windows' and get your HP-specific apps. Microsoft doesn't plan to make money from the store; the slides call it "revenue neutral".

Windows 8 multimedia
Windows 8 will have better media playback and recording, but it will balance using hardware acceleration to save battery life and using the CPU when it gives a better result.
Audio will use hardware acceleration more because that does improve battery life. There will be post-processing to take out blur, noise and shakey video filmed on a phone or webcam, and support for more codecs including AVC and as-yet-undetermined 3D video codecs (stereoscopic3D support is coming, for games and for 3D movies in Media Center, but there are format issues).
Microsoft talks about sharing 'with nearby devices'; one way that will work is adding the Play To option currently in Windows Media Player to the browser for HTML 5 audio and video content, so you can play it on any device that supports DLNA, another is APIs to let other software do the same.
That will work with DRM content, if it's protected with DTCP-IP (digital transmission content protection over IP) or Microsoft's own PlayReady and hardware acceleration will speed up DRM decoding.
There's also a new 'remote display' option that will let you send your screen from a laptop to a large monitor (which will use DirectX hardware acceleration and the same multimonitor interface that's already in Windows 7, but for wireless displays as well, which could be an Internet-connected TV - Microsoft refers to 35% of TVs having network connectivity by 2012 and wonders whether to prioritise Internet TV over further improvements to broadcast TV).

Twitter Delicious Facebook Digg Stumbleupon Favorites More