diff --git a/pkg/android/AndroidManifest.xml b/pkg/android/AndroidManifest.xml index 327a0954..4caa296e 100644 --- a/pkg/android/AndroidManifest.xml +++ b/pkg/android/AndroidManifest.xml @@ -4,11 +4,50 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pkg/android/src/org/gpxsee/gpxsee/Activity.java b/pkg/android/src/org/gpxsee/gpxsee/Activity.java new file mode 100644 index 00000000..98d51877 --- /dev/null +++ b/pkg/android/src/org/gpxsee/gpxsee/Activity.java @@ -0,0 +1,26 @@ +package org.gpxsee.gpxsee; + +import android.content.Intent; + +public class Activity extends org.qtproject.qt.android.bindings.QtActivity +{ + @Override + public void onNewIntent(Intent intent) + { + setIntent(intent); + } + + public String intentPath() + { + String path = ""; + + Intent intent = getIntent(); + if (intent != null) { + if (intent.getAction() == Intent.ACTION_VIEW) + path = intent.getDataString(); + setIntent(null); + } + + return path; + } +} diff --git a/src/GUI/app.cpp b/src/GUI/app.cpp index 91a8eaa1..a251abb0 100644 --- a/src/GUI/app.cpp +++ b/src/GUI/app.cpp @@ -6,6 +6,11 @@ #include #include #include +#ifdef Q_OS_ANDROID +#include +#include +#endif // Q_OS_ANDROID + #include "common/programpaths.h" #include "common/config.h" #include "common/downloader.h" @@ -102,6 +107,21 @@ void App::appStateChanged(Qt::ApplicationState state) { if (state == Qt::ApplicationSuspended) _gui->writeSettings(); + else if (state == Qt::ApplicationActive) { + QJniObject activity = QNativeInterface::QAndroidApplication::context(); + QString path(activity.callObjectMethod("intentPath").toString()); + if (!path.isEmpty()) { + if (!_gui->openFile(path, true)) { + MapAction *a; + if (!_gui->loadMap(path, a, true)) + _gui->openFile(path, false); + else { + if (a) + a->trigger(); + } + } + } + } } #endif // Q_OS_ANDROID