How to set a Qt app for Android as a Launcher?
-
Creating a Qt and QML app for Android is very convenient with Qt Creator. It’s perfect for quick prototypes. Is it also possible to setup a Qt app as an Android Launcher. I have realized, that Qt Creator creates the Android project structure in the build directory, that includes the AndroidManifest.xml file.
In Android Studio it’s quite simple to setup an app as a launcher by a small modification for the intend filter:
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter>
Can I configure my Qt project in a way, that modifies this intend filter?
-
Hi,
AFAIK, you can generate the AndroidManifest.xml for your project within the sources. You can then modify it the way you want it.
-
@sgaist Thanks for your reply. Sounds promising. How can I set up a manifest file? I had a look at the Qt Notifier example project. I assume the following parts of the .pro file are relevant I have to add to my .pro file:
QT += quick androidextras ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources OTHER_FILES += \ android-sources/AndroidManifest.xml
A have also seen, that Qt Creator is able to parse the manifest file and display a form. Here I can define the app name and app icon. Very useful. However the form doesn’t allow to edit the activity and intent filter. So I have to open the text editor.
Do you have a suggestion how to create a manifest file? I may take the one, that is automatically created during the build process of my project?
-
See the Editing Manifest File section in the Android deployment part of the Qt Creator documentation.
-
This post is deleted!
-
Hi All,
I'm also new to this topic,
I used the same intent defintion in androidmanifest xml file but Android is not considering my app to be a launcher app (nothing happens when I press on home button)
<activity android:name="org.qtproject.qt.android.bindings.QtActivity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:label="-- %%INSERT_APP_NAME%% --" android:launchMode="singleApp" android:screenOrientation="unspecified" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.HOME"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/> <meta-data android:name="android.app.arguments" android:value="-- %%INSERT_APP_ARGUMENTS%% --"/> <meta-data android:name="android.app.extract_android_style" android:value="minimal"/> </activity> <provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.qtprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/qtprovider_paths"/> </provider> </application>