diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> | 2014-02-14 10:25:23 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-15 22:25:36 +0100 |
commit | 8d721b3c567aeecb04a39a3f75b76f5ef10db25c (patch) | |
tree | 807d3d48636d6cb87bc2578505f6710eb70026b8 /src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java | |
parent | c9cdbcb12f80cd72905e49ce1a673eae9f559ca3 (diff) |
Android: Add enablers for listening to activity results
When you launch an activity through an intent,
data can be provided back from the activity when it has finished
using onActivityResult() in the activity which launched it.
This is okay for applications, since they can easily create their
own activities, but does not work for libraries that need to
use intents. There is no listener API for activity results which
allow external classes to eavesdrop.
In order to support launching intents from third-party or add-on
libraries, we provide a low-level way to hook into the activity
result event. The corresponding public API will be added to
QtAndroidExtras.
Change-Id: I89417f485e2c0e69028dcccc7c155788346a7417
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java')
-rw-r--r-- | src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java index 356c096a9a..4b80d68761 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -44,6 +44,7 @@ package org.qtproject.qt5.android; import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; @@ -86,6 +87,7 @@ public class QtActivityDelegate private Method m_super_onKeyDown = null; private Method m_super_onKeyUp = null; private Method m_super_onConfigurationChanged = null; + private Method m_super_onActivityResult = null; private static final String NATIVE_LIBRARIES_KEY = "native.libraries"; private static final String BUNDLED_LIBRARIES_KEY = "bundled.libraries"; @@ -410,6 +412,7 @@ public class QtActivityDelegate m_super_onKeyDown = m_activity.getClass().getMethod("super_onKeyDown", Integer.TYPE, KeyEvent.class); m_super_onKeyUp = m_activity.getClass().getMethod("super_onKeyUp", Integer.TYPE, KeyEvent.class); m_super_onConfigurationChanged = m_activity.getClass().getMethod("super_onConfigurationChanged", Configuration.class); + m_super_onActivityResult = m_activity.getClass().getMethod("super_onActivityResult", Integer.TYPE, Integer.TYPE, Intent.class); } catch (Exception e) { e.printStackTrace(); return false; @@ -720,6 +723,18 @@ public class QtActivityDelegate } } + public void onActivityResult(int requestCode, int resultCode, Intent data) + { + try { + m_super_onActivityResult.invoke(m_activity, requestCode, resultCode, data); + } catch (Exception e) { + e.printStackTrace(); + } + + QtNative.onActivityResult(requestCode, resultCode, data); + } + + public void onStop() { QtNative.updateApplicationState(ApplicationSuspended); |