diff options
Diffstat (limited to 'examples/network/http/main.cpp')
-rw-r--r-- | examples/network/http/main.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/examples/network/http/main.cpp b/examples/network/http/main.cpp index f126c7846a..6c86933fd6 100644 --- a/examples/network/http/main.cpp +++ b/examples/network/http/main.cpp @@ -53,16 +53,39 @@ #include <QScreen> #include "httpwindow.h" +#ifdef REQUEST_PERMISSIONS_ON_ANDROID +#include <QtAndroid> + +bool requestStoragePermission() { + using namespace QtAndroid; + + QString permission = QStringLiteral("android.permission.WRITE_EXTERNAL_STORAGE"); + const QHash<QString, PermissionResult> results = requestPermissionsSync(QStringList({permission})); + if (!results.contains(permission) || results[permission] == PermissionResult::Denied) { + qWarning() << "Couldn't get permission: " << permission; + return false; + } + + return true; +} +#endif int main(int argc, char *argv[]) { QApplication app(argc, argv); - +#ifdef REQUEST_PERMISSIONS_ON_ANDROID + if (!requestStoragePermission()) + return -1; +#endif HttpWindow httpWin; const QRect availableSize = httpWin.screen()->availableGeometry(); httpWin.resize(availableSize.width() / 5, availableSize.height() / 5); httpWin.move((availableSize.width() - httpWin.width()) / 2, (availableSize.height() - httpWin.height()) / 2); - +#ifdef Q_OS_ANDROID + httpWin.showMaximized(); +#else httpWin.show(); +#endif + return app.exec(); } |