Android: Make it possible to pass arguments via intent extras

Needed for autotest script, so that we can pass command line
arguments to Qt Test.

This can now be done by:

% adb shell am start \
            -e applicationArguments "argument1 argument2" \
            <INTENT>

Change-Id: I772209f66da055c6a0b01b709f36e33fdb5c2ed6
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2013-10-10 14:49:47 +02:00 committed by The Qt Project
parent 5c64847ba3
commit 4be5d58203
2 changed files with 10 additions and 5 deletions

View File

@ -489,6 +489,14 @@ public class QtActivity extends Activity
+ "\tQML2_IMPORT_PATH=" + localPrefix + "/qml"
+ "\tQML_IMPORT_PATH=" + localPrefix + "/imports"
+ "\tQT_PLUGIN_PATH=" + localPrefix + "/plugins");
Intent intent = getIntent();
if (intent != null) {
String parameters = intent.getStringExtra("applicationArguments");
if (parameters != null)
loaderParams.putString(APPLICATION_PARAMETERS_KEY, parameters.replace(' ', '\t'));
}
loadApplication(loaderParams);
return;
}

View File

@ -419,14 +419,11 @@ static jboolean startQtAndroidPlugin(JNIEnv* /*env*/, jobject /*object*//*, jobj
static void *startMainMethod(void */*data*/)
{
char const **params;
params = static_cast<char const **>(malloc(m_applicationParams.length() * sizeof(char *)));
QVarLengthArray<const char *> params(m_applicationParams.size());
for (int i = 0; i < m_applicationParams.size(); i++)
params[i] = static_cast<const char *>(m_applicationParams[i].constData());
int ret = m_main(m_applicationParams.length(), const_cast<char **>(params));
free(params);
int ret = m_main(m_applicationParams.length(), const_cast<char **>(params.data()));
Q_UNUSED(ret);
if (m_mainLibraryHnd) {