我正在使用 ZXing 作为库项目的 PhoneGap 条形码扫描仪插件。
我有一个在 Galaxy Tab 2 (7") 上完美运行的代码。相同的代码在 Galaxy S3 上不起作用。
问题:当 ZXing CaptureActivity 扫描条形码时,它只是完成了 CaptureActivity 并且 Calling 活动永远不会通过 onActivityResult 方法返回。
主要节日。
<activity
android:name=".activity.MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.zxing.client.android.CaptureActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden" >
<intent-filter>
<action android:name="com.phonegap.plugins.barcodescanner.SCAN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
MainActivity.java
public void startActivityForResult(CordovaPlugin command, Intent intent,
int requestCode) {
this.activityResultCallback = command;
this.activityResultKeepRunning = this.keepRunning;
// If multitasking turned on, then disable it for activities that return
// results
if (command != null) {
this.keepRunning = false;
}
// Start activity
startActivityForResult(intent, requestCode);
}
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
CordovaPlugin callback = this.activityResultCallback;
if (callback != null) {
callback.onActivityResult(requestCode, resultCode, intent);
} else {
Log.e(TAG, "Plugin callback null");
}
// else continue with any other code you need in the method
super.onActivityResult(requestCode, resultCode, intent);
}
条码扫描器插件
private static final String SCAN_INTENT = "com.phonegap.plugins.barcodescanner.SCAN";
public void scan() {
Intent intentScan = new Intent(SCAN_INTENT);
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
this.cordova.startActivityForResult((CordovaPlugin) this, intentScan,
AppConstants.CAMERA_SCAN_REQUEST_CODE);
}
我有 ZXing 项目作为图书馆项目。
帮助将不胜感激。