summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-02-14 10:25:23 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-15 22:25:36 +0100
commit8d721b3c567aeecb04a39a3f75b76f5ef10db25c (patch)
tree807d3d48636d6cb87bc2578505f6710eb70026b8 /src/android
parentc9cdbcb12f80cd72905e49ce1a673eae9f559ca3 (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')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java15
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtNative.java3
2 files changed, 18 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);
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
index 81d70ddc9a..9b716f74e5 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
@@ -598,4 +598,7 @@ public class QtNative
public static native boolean onContextItemSelected(int itemId, boolean checked);
public static native void onContextMenuClosed(Menu menu);
// menu methods
+
+ // activity methods
+ public static native void onActivityResult(int requestCode, int resultCode, Intent data);
}