QtOnAndroid

Manifest

QML Accelerometer Example | | Google Play Store

The camera example require access to a specific hardware feature of the mobile device. The user needs to grant access to such a feature beforehand with Android.

Those permissions are defined in the so called Android Manifest - an XML document which accompanies the source code. Besides permissions the following app properties are defined as well:

  • Application name and organization
  • Version
  • API level
  • Main activity configuration
  • Behavior on screen rotation
  • Intents to be delivered to the app

In Qt Creator we create a default Manifest in the Android sections of the “Build” dialog.

Then the following (or similar) XML document is created:

[<?xml version="1.0"?>
<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
    <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Ping" android:icon="@drawable/icon">
        <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="@string/app_name" android:screenOrientation="unspecified" android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            ...
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
    <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>

For the camera example the following permissions are required:

   <uses-permission android:name=“android.permission.CAMERA”/>
   <uses-permission android:name=“android.permission.FLASHLIGHT”/>

The Manifest file needs to be included in the APK so that we add the following lines in the qmake project:

ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
OTHER_FILES += android/AndroidManifest.xml


QML Accelerometer Example | | Google Play Store

Options: