I am using the Barcode Scanner Plugin for PhoneGap, using ZXing as a library project.
I have a code that works fine on the Galaxy Tab 2 (7 "). The same code does not work on the Galaxy S3.
Problem: When ZXing CaptureActivity scans a barcode, it simply finishes the CaptureActivity and Calling operation, which is never returned using the onActivityResult method.
MainFest.
<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); }
BarcodeScanner Plugin
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); }
I have a ZXing project as a library project.
Help will be appreciated.
android android-intent cordova barcode-scanner zxing
Valaypatel
source share