Submit argument(s) to a program restart on Android
Unsolved
Mobile and Embedded
-
Hi,
I need to be able to restart my App. On the Android platform I do this as proposed here by Bogdan. It works flawlessly.Unfortunately I don't have the slightest idea, how (or even if) I can provide arguments to my pendingIntent. I have (naively) tried:
QAndroidJniObject arg = QAndroidJniObject::fromString("Camera"); alarmManager.callMethod<void>("set", "(IJLandroid/app/PendingIntent;)V", QAndroidJniObject::getStaticField<jint>("android/app/AlarmManager", "RTC"), jlong(QDateTime::currentMSecsSinceEpoch() + 500), pendingIntent.object(), arg.object());
But it didn't show up as an argument in my app. On Windows,
QProcess::startDetached(programName, arguments);
does that trick, but I don't know how to provide the information here.
Any idea - including a tipp on where to read about this stuff - is highly appreciated.
I have tried to understand the man pages of PendingIntent and AlarmManager, but I don't see what I am looking for.Here's what I do so far:
int main(int argc, char *argv[]) { ///... (shortened) QStringList arguments; if (currentExitCode == Controller::EXIT_CODE_REBOOT_TO_CAMERA) { arguments<<"Camera"; } if (currentExitCode == Controller::EXIT_CODE_REBOOT || currentExitCode == Controller::EXIT_CODE_REBOOT_TO_CAMERA) { ///... (shortened) #ifdef Q_OS_ANDROID auto activity = QtAndroid::androidActivity(); auto packageManager = activity.callObjectMethod("getPackageManager", "()Landroid/content/pm/PackageManager;"); auto activityIntent = packageManager.callObjectMethod("getLaunchIntentForPackage", "(Ljava/lang/String;)Landroid/content/Intent;", activity.callObjectMethod("getPackageName", "()Ljava/lang/String;").object()); auto pendingIntent = QAndroidJniObject::callStaticObjectMethod("android/app/PendingIntent", "getActivity", "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;", activity.object(), jint(0), activityIntent.object(), QAndroidJniObject::getStaticField<jint>("android/content/Intent", "FLAG_ACTIVITY_CLEAR_TOP")); auto alarmManager = activity.callObjectMethod("getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;", QAndroidJniObject::getStaticObjectField("android/content/Context", "ALARM_SERVICE", "Ljava/lang/String;").object()); alarmManager.callMethod<void>("set", "(IJLandroid/app/PendingIntent;)V", QAndroidJniObject::getStaticField<jint>("android/app/AlarmManager", "RTC"), jlong(QDateTime::currentMSecsSinceEpoch() + 500), pendingIntent.object()); #endif } qApp->quit(); app->deleteLater(); return currentExitCode; }