diff --git a/android-integration/build.xml b/android-integration/build.xml
index 3dc7622d7..3dffdfa85 100644
--- a/android-integration/build.xml
+++ b/android-integration/build.xml
@@ -35,7 +35,7 @@
deprecation="true"
includeantruntime="false">
-
+
diff --git a/android-integration/pom.xml b/android-integration/pom.xml
index 65aa41e5c..c559d8042 100644
--- a/android-integration/pom.xml
+++ b/android-integration/pom.xml
@@ -60,7 +60,7 @@
com.google.android
android
provided
- 2.1.2
+ 4.0.1.2
diff --git a/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java b/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java
index 68a13d2e3..976f50f07 100644
--- a/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java
+++ b/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java
@@ -92,7 +92,7 @@ import android.util.Log;
* @author Brad Drehmer
* @author gcstang
*/
-public final class IntentIntegrator {
+public class IntentIntegrator {
public static final int REQUEST_CODE = 0x0000c0de; // Only use bottom 16 bits
private static final String TAG = IntentIntegrator.class.getSimpleName();
@@ -235,9 +235,23 @@ public final class IntentIntegrator {
intentScan.setPackage(targetAppPackage);
intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
- activity.startActivityForResult(intentScan, REQUEST_CODE);
+ startActivityForResult(intentScan, REQUEST_CODE);
return null;
}
+
+ /**
+ * Start an activity.
+ * This method is defined to allow different methods of activity starting for
+ * newer versions of Android and for compatibility library.
+ *
+ * @param intent Intent to start.
+ * @param code Request code for the activity
+ * @see android.app.Activity#startActivityForResult(Intent, int)
+ * @see android.app.Fragment#startActivityForResult(Intent, int)
+ */
+ protected void startActivityForResult(Intent intent, int code) {
+ activity.startActivityForResult(intent, code);
+ }
private String findTargetAppPackage(Intent intent) {
PackageManager pm = activity.getPackageManager();
diff --git a/android-integration/src/com/google/zxing/integration/android/IntentIntegratorV30.java b/android-integration/src/com/google/zxing/integration/android/IntentIntegratorV30.java
new file mode 100644
index 000000000..20d0a590b
--- /dev/null
+++ b/android-integration/src/com/google/zxing/integration/android/IntentIntegratorV30.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.zxing.integration.android;
+
+import android.app.Fragment;
+import android.content.Intent;
+
+/**
+ * IntentIntegrator for Android version 3.0 and beyond.
+ *
+ * @author Lachezar Dobrev
+ */
+public final class IntentIntegratorV30 extends IntentIntegrator {
+
+ private final Fragment fragment;
+
+ /**
+ * @param fragment Fragment to handle activity response.
+ */
+ public IntentIntegratorV30(Fragment fragment) {
+ super(fragment.getActivity());
+ this.fragment = fragment;
+ }
+
+ @Override
+ protected void startActivityForResult(Intent intent, int code) {
+ fragment.startActivityForResult(intent, code);
+ }
+
+}
\ No newline at end of file