qt android

30
Create a cross-platform application with Qt

Upload: adeneo-embedded

Post on 18-Aug-2015

167 views

Category:

Technology


0 download

TRANSCRIPT

Create a cross-platform application with Qt

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Qt 5.4 for Android package

content

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Qt 5.4 for Android package

content

• Supported for Android versions 2.3.3 (API 10) or later

• Qt 5 • C++, Qt Quick

• Sensors reading, and multimedia features are fully supported

• Network, database, …

• Qt Creator IDE : Powerful cross‐platform integrated development environment including UI designer tools

• Tools and toolchains : Embedded toolchains for ARMV7 and x86 platforms, QtLinguist, …

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Installation requirements

• Some external tools needed

• The Android SDK tools

• The Android NDK

• Apache Ant v1.8 or later

• JDK v6 or later

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Installation requirements

• Qt for android

• Prebuilt binaries for Linux and windows

• http://qt-project.org/downloads

• Qtcreator:

• Support QtGUI, QtQUICK1/2, Console

• Manage the “Kits”

• Setup location of the android SDK+NDK

• Start AVD

• Deploy application

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Installation requirements

• Qt for android

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Supported Items

• Qt Widgets and QML Applications

• QML media player functionality in Qt Multimedia

• A set of sensors in Qt Sensors

• Deploying app to a device from Qt Creator

• Complete support of Qt components in Qt 5.4 release

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Compatibility map : Qt

Sensors

Feature Android

Accelerometer

Altimeter

Ambient Light Sensor

Ambient Temperature Sensor

Compass

Gyroscope

Holster Sensor

IR Proximity Sensor

Light Sensor

Magnetometer

Orientation Sensor

Pressure Sensor

Proximity Sensor

Rotation Sensor

Tap Sensor

Tilt Sensor

Sensor Gestures

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Deployment

Three methods to deploy Qt applications on Android:

• Bundle Qt libraries and files into the apk • Provide stand-alone and distributable application package

• Using Ministro • Minimize the size of the APK by sharing Qt libraries across all Qt based

applications

• Debugging • More convenient when testing an application on a device physically

connected to the development machine

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Deployment

Three methods to deploy Qt applications on Android:

• Projects

– <Choose you kit>

• Deploy configurations

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Deployment

Using ministro:

• Available on Google Play

• The application will ask ministro for Qt components

• Ministro can download required components: • If they are not installed

• If newer versions exist

• GPLv3+ license for the APK

• BSD License for the API

• Install LGPLv2.1 / GPLv3 Qt libraries

• Make Qt libraries available to all Qt based applications

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Deployment

Deployed by qtcreator or in the APK

• Select the Kit

• Make sure that an AVD is declared (sdk/tools/android avd)

• Running the project will start the AVD deploy the libaries and run the application using adb push and adb install

• Deploy in the APK for production

• Deploy to device for debugging (platform dev)

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Deployment

On an Android emulator On a real Android device

On a Embedded Android device

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Project architecture

• Qt base project

• Project file configuration .pro

• C++ sources and headers .cpp/.h

• QML, javascript .qml/.js

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Project architecture

• Android activity

• Java files

• Entry point of the application

• Load Qt application and execute native code

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Project architecture

• Resource files • Contains android specific files

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Project architecture

• AndroidManifest.xml • Provide meta-information about the app

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Project architecture

• QtApplication.java – Qapplication for android

– Java Application class that handle global state

– Uses the Java reflection API

• QtActivity.java – Only one activity used to render Qt: Qt Platform Abstraction API

(QPA) • Graphics

• Events propagations

• Clipboard

• …

– Interface with ministro

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Qt Quick : Design

sophisticated GUI

• Perfectly fitted for Android and mobile devices • Gestures, animations

• Network transparent, sensors

• Design oriented • GUI conception accessible to designers

• Simple components to create your own UI

• Completely separate UI and logic

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Qt Quick : Design

sophisticated GUI

• Completely separate UI and logic • Allows switching UI at runtime

• Access C++ through bindings and functions • C++ and UI data automatically synchronized

Development

User interface .qml

Source code .cpp/.h

Application

Scripts .js C++ Data

Objects

User interface .qml .

Scripts .js

Execution

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

How to use Android API ?

• Work with JNI

• Call OS specific functions

• Use functionalities not supported yet by Qt

• Communicate with others applications

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

How to use Android API ?

• On C++ side • JNI is loaded when application starts

• We need to → Get the JNI environment

→ Get a pointer on Java Virtual Machine

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

How to use Android API ?

• On Java side → Implement Java methods

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

New features in Qt 5.4

• Fully support development of Qt applications for Android

• New module : Qt Android Extras for integration with native code on Android

• Webkit is not supported, but all the following modules are supported

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

New features in Qt 5.4

• QQuickWidget is now supported, to easily integrate a QQuick GUI into a widget based application

• Qt Positioning : Android supports position and satellite updates

• Qt Bluetooth allows connecting to remote devices through a RFCOMM channel using the Serial Port Profile (SPP)

• Qt Network module with a new bearer plugin for Android

• Qt Purchasing API is currently supported for Android (Google Play) for monetization

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Native Android Look

• Qt helps developers by providing native Android styling of the graphical user interface, matching Android buttons and components appearance and behavior.

• The new look and feel of Android 5.0, Material design, is only partially supported.

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Licenses

• Qt Company proposes a dual licensing :

– Qt Open Source

– Qt commercial : full rights to modify source code, Qt support Help desk, Qt & QtQuick new components, additional tools, Boot To Qt (Enterprise), Embedded platforms support (Enterprise), applications’ distribution through application stores (Indie Mobile) and Qt Cloud Services

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Publication on the PlayStore

• First store for distributing Android applications

• With Indie Mobile license, it is possible to distribute applications via whatever third party application store you wish.

• Steps :

– Sign the .apk

– Publish the application on Google Play

– Monetize it

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Speedometer sample

application

• Demo

www.adeneo-embedded.com

©2014 Adeneo Embedded & Subsidiaries. All Rights Reserved.

This document and the information it contains is confidential and remains the property of our company. It may not be copied or communicated to a third party or used for any purpose other than that for which it is supplied without the prior written consent of our company.

Conclusion

• Qt offers new ways for developing Android applications

• It is a good alternative to Java & HTML cross platform frameworks

• It continues to evolve

• Qt 5.5 has more planned and should be released at the end of April 2015.