Evgenij LegotskojDec. 11, 2015, 10:18 a.m.

QML - Lesson 020. Introduction to Android Manifest in Qt Creator

Content

When it comes time to lead the development of Android on Qt, this is sooner or later we arrive at the need to work with the file AndroidManifest.xml. In this file, we have the ability to specify certain basic settings for the behavior of our application, such as the orientation of the screen, or the main theme of the application.

But the default Android Manifest in Qt Creator is not created. To start working with him, it will be necessary to create it in the project build options.

Step by step with the Android Manifest

First step

To do this, go to the Projects tab and in it we find the necessary assembly kit. Select Build, and in it find item Collect Android APK. Razvernёm this item by clicking on the "Read More".

Here you can select the target level of the SDK and configure APK building.

Second step

But to create the AndroidManifest.xml file, you will need to click on the button "Create a template." And then select the folder where the Android Manifest will be created.

The third step

The project structure you see AndroidManifest.xml file. And the right of the structure is open setup of the file. Here you can set the minimum required device SDK, on which the installation is carried out, as well as set the icon of the application and include the required permissions for the application. For example, calls, internet access, work with Wi-Fi, etc.

Fourth step

After you set up the basic parameters of the application, I propose to look at himself xml file code that generated QtCreator. This code will be similar to the code that you see in AndroidManifst.xml when developing an application for Android in Java. Therefore, setting the file will be similar to the development of a Java. And, for example, setting fikisrovannoy orientation of the screen will look as follows:

<activity 
...
android:screenOrientation="landscape" >
...
</activity>

Well, the full code of the resulting Android Manifest I looked like this.

<?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="-- %%INSERT_APP_NAME%% --">
        <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_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>
            <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
            <meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
            <meta-data android:name="android.app.repository" android:value="default"/>
            <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
            <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
            <!-- Deploy Qt libs as part of package -->
            <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
            <meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
            <meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
            <!-- Run with local libs -->
            <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
            <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
            <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
            <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
            <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
            <!--  Messages maps -->
            <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
            <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
            <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
            <!--  Messages maps -->

            <!-- Splash screen -->
            <!--
            <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/>
            -->
            <!-- Splash screen -->

            <!-- Background running -->
            <!-- Warning: changing this value to true may cause unexpected crashes if the
                          application still try to draw after
                          "applicationStateChanged(Qt::ApplicationSuspended)"
                          signal is sent! -->
            <meta-data android:name="android.app.background_running" android:value="false"/>
            <!-- Background running -->
        </activity>
    </application>
    <uses-sdk android:targetSdkVersion="14"/>
    <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>

    <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
         Remove the comment if you do not require these default permissions. -->
    <!-- %%INSERT_PERMISSIONS -->

    <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
         Remove the comment if you do not require these default features. -->
    <!-- %%INSERT_FEATURES -->

</manifest>

Conclusion

Working with Qt under AndroidManifest.xml has its own specifics, but it's still not so very different from that as if we were developing in Java.

You can also look profile project. In it you'll see how the project is connected to your Android Manifest .

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.
Support the author Donate

Comments

Only authorized users can post comments.
Please, Log in or Sign up
Timeweb

Let me recommend you the excellent hosting on which EVILEG is located.

For many years, Timeweb has been proving his stability.

For projects on Django I recommend VDS hosting

View Hosting
l
  • laxy93
  • Sept. 21, 2020, 3:37 a.m.

C++ - Test 006. Enumerations

  • Result:90points,
  • Rating points8
l
  • laxy93
  • Sept. 21, 2020, 3:28 a.m.

C++ - Test 005. Structures and Classes

  • Result:83points,
  • Rating points4
l
  • laxy93
  • Sept. 21, 2020, 3:22 a.m.

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:70points,
  • Rating points1
Last comments

QCheckBox в качестве делегата QTableView

До тех пор, пока у вас проект содержит только одну таблицу, или несколько то может быть. Когда их будет 1000 и чекбоксы в разных колонках, то без делегатов и переопределения возвращаемых ре…
D
  • Damir
  • Sept. 20, 2020, 3:34 p.m.

QCheckBox в качестве делегата QTableView

bool Node::setData(const QModelIndex& index, const QVariant& value, int role){ switch (index.column()) { case 0: switch (role) { case Qt::CheckStateRole:// <- т…
VB

Qt/C++ - Lesson 004. QSqlTableModel – How to present the table from database?

Почему-то такой метод для обновления не работает, который можно было бы применить в данном примере. То есть в представлении данные удаляются и обновляются, а в базе данных изменений не происходи…
DI

Qt/C++ - Lesson 015. QTableWidget – How to create a table with checkboxes?

Кажется я понял в чем ошибка - я вручную создал таблицу Device в базе данных DataBase.db через DB Browser for SQLite в корне проекта с соответствующими типами данных и по какой-то причине insert…
DI

Qt/C++ - Lesson 015. QTableWidget – How to create a table with checkboxes?

Да, у меня тоже такая мысль возникла, но я просто скопипастил этот код из статьи, ничего в нем не меняя.
Now discuss on the forum

2 форму на одной странице

а можно просто сделать вторую форму с разделением обработчиков <form action="{% url 'change_password_view' %}">{{ change_password_form }}<input type="submit"></form><…
KM

Siganal slot в ui

добрый день, хочу сделать сигнал слот между ui каунтером: выше (начало UI)ui->setupUi(this); timer = new QTimer(this); connect(timer, &QTimer::timeout, this, &Error…

виджет динамического размера в виджете постоянно заданого размера, цель: виджет родитель принимал размер виджета ребенка

Добрый день! Все классы, которые наследованы от QObject имеют метод parent() , вы можете попробовать сделать static_cast парент объекта и установить его размеры по ко…

Как в qml работать с динамически созданными потомками?

Добрый день В слове длина вы допустили ошибку. Если это то, что вы выводили в консоль, то тогда понятно, почему там было undefined. Надо было так _window.children.length …

Как в Qt в qmenu добавить scrollarea

Вот это наследованный класс меню. Но посути это обычное меню. #pragma once#include <QtWidgets>class TransMenu : public QMenu { Q_OBJECTpublic: TransMenu(QWidget* parent = …
About
Services
© EVILEG 2015-2020
Recommend hosting TIMEWEB