mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Add Fragment-friendly integration and bump requirement to Android 4.0 to build (not to use) since that's the only thing available in Maven beyond 2.x
git-svn-id: https://zxing.googlecode.com/svn/trunk@2119 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
a39e9d8163
commit
420e47efd1
|
@ -35,7 +35,7 @@
|
|||
deprecation="true"
|
||||
includeantruntime="false">
|
||||
<classpath>
|
||||
<pathelement location="${android-home}/platforms/android-7/android.jar"/>
|
||||
<pathelement location="${android-home}/platforms/android-15/android.jar"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
<jar jarfile="android-integration.jar" basedir="build"/>
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>2.1.2</version>
|
||||
<version>4.0.1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
|
|
@ -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.<br>
|
||||
* 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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue