181 | | ====== Modified QtActivity ====== |
| 181 | ====== Modified !QtActivity.java ====== |
| 182 | Another mportant file is the main Android ''activity'' located in {{{android/src/org/kde/necessitas/origo/QtActivity.java}}} This is actually the first thing that is started once you press the application icon on android. It basically works as a glue between Android, Qt and in our case, Python & PySide. |
| 183 | |
| 184 | The basic activity file that is part of every Necessitas Qt Creator project has been modified by the ''android_python27'' project, to look for two specific zip archives in the installation folder at startup ant to decompress them & then remover the archives. |
| 185 | |
| 186 | This way bundling of arbitrary files (libraries, executables, code, themes, etc.) inside the application APK has been achieved. |
| 187 | |
| 188 | '''NOTE:''' Necessitas Qt Creator might sometimes want to update the pre-generated *.java files with a new version. If this happens to you, check if the update didn't break or remove the bundling code in {{{QtActivity.java}}} . |
| 189 | |
| 190 | ====== !GlobalConstants.java ====== |
| 191 | The file {{{android/src/org/kde/necessitas/origo/GlobalConstants.java}}} contains variables for the main {{{QtActivity}}} file. |
| 192 | |
| 193 | It looks like this: |
| 194 | |
| 195 | {{{ |
| 196 | package org.kde.necessitas.origo; |
| 197 | |
| 198 | public class GlobalConstants { |
| 199 | |
| 200 | public static final String PYTHON_MAIN_SCRIPT_NAME = "main.py"; |
| 201 | public static final String PYTHON_PROJECT_ZIP_NAME = "my_python_project.zip"; |
| 202 | public static final String PYTHON_ZIP_NAME = "python_27.zip"; |
| 203 | public static final String PYTHON_EXTRAS_ZIP_NAME = "python_extras_27.zip"; |
| 204 | |
| 205 | public static final boolean IS_FOREGROUND_SERVICE = true; |
| 206 | |
| 207 | public static final String PYTHON_BIN_RELATIVE_PATH = "/python/bin/python"; |
| 208 | public static final String PYTHON_NAME = "python"; |
| 209 | public static final String PYTHON_NICE_NAME = "Python 2.7.2"; |
| 210 | |
| 211 | public static String[] SCRIPT_ARGS = { "--foreground" }; |
| 212 | |
| 213 | public static final String LOG_TAG = "PythonAPK"; |
| 214 | } |
| 215 | |
| 216 | }}} |
| 217 | As you can see, you can use it to set various variables, such as name of the bundling archives or logging prefix (does this actually work ?). |