Commit af20ed6e authored by Volker Krause's avatar Volker Krause
Browse files

Add basic support for opening files via Android Intents

This works for file URLs, but this doesn't resolve content URLs yet that
e.g. the default file manager seems to use for standard locations.
parent 8f1318d7
......@@ -27,6 +27,11 @@
#include <QQmlApplicationEngine>
#include <QQmlContext>
#ifdef Q_OS_ANDROID
#include <QtAndroid>
#include <QAndroidJniObject>
#endif
#include <QCommandLineParser>
#include <QGuiApplication>
#include <QIcon>
......@@ -69,5 +74,20 @@ int main(int argc, char **argv)
for (const auto &file : parser.positionalArguments())
passMgr.importPass(QUrl::fromLocalFile(file));
#ifdef Q_OS_ANDROID
// handle opened files
const auto activity = QtAndroid::androidActivity();
if (activity.isValid()) {
const auto intent = activity.callObjectMethod("getIntent", "()Landroid/content/Intent;");
if (intent.isValid()) {
const auto data = intent.callObjectMethod("getDataString", "()Ljava/lang/String;");
if (data.isValid()) {
// TODO handle content:// urls
passMgr.importPass(QUrl(data.toString()));
}
}
}
#endif
return app.exec();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment