From 210b6081a58d6616287ee45f66a2c41306c74e7d Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Thu, 3 Jan 2019 10:49:58 +0100
Subject: [PATCH] Add a QtAndroid::startActivity that takes a QAndroidIntent

The function simply calls the other startActivity with
QAndroidIntent::handle, anyone could do that from the user code, but i
think it makes sense the library to allow you doing this directly given
you're supposed to pass an intent and we have a class that represents an
intent

Change-Id: I673cb410b07ed4fd1408a971696a3b5ae3dfd063
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
---
 .../android/qandroidfunctions.cpp             | 21 +++++++++++++++++++
 src/androidextras/android/qandroidfunctions.h |  3 +++
 2 files changed, 24 insertions(+)

diff --git a/src/androidextras/android/qandroidfunctions.cpp b/src/androidextras/android/qandroidfunctions.cpp
index a5ed23d..651cf32 100644
--- a/src/androidextras/android/qandroidfunctions.cpp
+++ b/src/androidextras/android/qandroidfunctions.cpp
@@ -180,6 +180,27 @@ void QtAndroid::startActivity(const QAndroidJniObject &intent,
     }
 }
 
+/*!
+  \since 5.13
+
+  Starts the activity given by \a intent and provides the result asynchronously through the
+  \a resultReceiver if this is non-null.
+
+  If \a resultReceiver is null, then the \c startActivity() method in the \c androidActivity()
+  will be called. Otherwise \c startActivityForResult() will be called.
+
+  The \a receiverRequestCode is a request code unique to the \a resultReceiver, and will be
+  returned along with the result, making it possible to use the same receiver for more than
+  one intent.
+
+ */
+void QtAndroid::startActivity(const QAndroidIntent &intent,
+                              int receiverRequestCode,
+                              QAndroidActivityResultReceiver *resultReceiver)
+{
+    startActivity(intent.handle(), receiverRequestCode, resultReceiver);
+}
+
 /*!
   \since 5.3
 
diff --git a/src/androidextras/android/qandroidfunctions.h b/src/androidextras/android/qandroidfunctions.h
index 8dba435..c6802e8 100644
--- a/src/androidextras/android/qandroidfunctions.h
+++ b/src/androidextras/android/qandroidfunctions.h
@@ -68,6 +68,9 @@ namespace QtAndroid
     Q_ANDROIDEXTRAS_EXPORT void startActivity(const QAndroidJniObject &intent,
                                               int receiverRequestCode,
                                               QAndroidActivityResultReceiver *resultReceiver = nullptr);
+    Q_ANDROIDEXTRAS_EXPORT void startActivity(const QAndroidIntent &intent,
+                                              int receiverRequestCode,
+                                              QAndroidActivityResultReceiver *resultReceiver = nullptr);
 
     enum class BindFlag {
         None                = 0x00000000,
-- 
GitLab