I have an Ionic app that has the Cordova Barcode Scanner to scan the UPC number. It works fine on iOS and returns the results as expected. However on Android Marshmallow 6.1 tablet it scans and shows the message Product found on the camera screen but doesn't return any values to my view as expected. I have scanned through my entire app and no where I have the text Product found. Not sure what is the source of this message. Please help.
I have implemented barcodeScanner/qrScanner and i tested it on Android Marshmallow 6.1. It works fine for me. what is the specific error and would you like me to post any screen-shot or code snippet ?
@anuj-786 it doesn't spit an error. It scans but doesn't assign it to the scope or if I do an alert for image.text nothing pops up. Looks like it calls google products api and returns a message Product found and goes back to the parent view
Below is my code that works fine for iOS but not Android
$cordovaBarcodeScanner.scan().then(function(imageData) {
$scope.cancelled = imageData.cancelled;
if($scope.cancelled === 0) {
$scope.produpc = imageData.text;
var myupc = $scope.produpc;
console.log('UPC Number is ' + myupc);
}
Other actions including a web service call.
I even tried using $scope.apply to force the assignment of the values to both cancelled as well as produpc but no success.
ok I got your details. before that i want to ask you that this is working fine with simple barcode or not working for all types.
Please follow this link it will help you.
https://www.thepolyglotdeveloper.com/2014/09/implement-barcode-scanner-using-ionic-framework/
It doesn't work for s simple barcode such as upc or upc-a. The problem is for android only. If you look into the xml files that come with android version of the plugin it has references to google products and books. It means there has to be configuration options to disable them. What device are you testing on? The example you have posted above works for iOS but not android.
Anuj - I tried it for Android 5.1 as well. Same issue. You can see this Product found message. I have search through my app code as well as the code for my apis. None works. Please see the URL below:
https://drive.google.com/open?id=0B81YQAjfP0R2VmU2V1I1QTg3NWc
Also see the iOS version of it that is fully functional:
https://drive.google.com/open?id=0B81YQAjfP0R2RkhEeVlOVUlLUmc
Please see the debug code below. nothing is published in the console when barcode scanner is called.
D/PowerManagerService( 946): turnOffButtonLight mButtonLightTimeout = 2000
D/PowerManagerService( 946): Trun on the button and after 2000s,then turn off the button !
D/AutomaticBrightnessController( 946): ZTE_PM_LIGHT updateAmbientLux: mLightSensorListener lux is 9.0
D/AutomaticBrightnessController( 946): ZTE_PM_LIGHT updateAmbientLux: mLightSensorListener lux is 14.0
D/PowerManagerService( 946): turnOffButtonLight mButtonLightTimeout = 2000
D/AutomaticBrightnessController( 946): ZTE_PM_LIGHT updateAmbientLux: mLightSensorListener lux is 3.0
D/PowerManagerService( 946): Trun on the button and after 2000s,then turn off the button !
D/AutomaticBrightnessController( 946): ZTE_PM_LIGHT updateAmbientLux: mLightSensorListener lux is 12.0
D/AutomaticBrightnessController( 946): ZTE_PM_LIGHT updateAmbientLux: mLightSensorListener lux is 9.0
D/PowerManagerService( 946): turnOffButtonLight mButtonLightTimeout = 2000
D/ConnectivityService( 946): updateNetworkScore for NetworkAgentInfo [WIFI () - 109] to 51
D/ConnectivityService( 946): rematching NetworkAgentInfo [WIFI () - 109]
D/ConnectivityService( 946): Network NetworkAgentInfo [WIFI () - 109] was already satisfying request 1. No change.
D/ConnectivityService( 946): notifyType AVAILABLE for NetworkAgentInfo [WIFI () - 109]
D/AutomaticBrightnessController( 946): ZTE_PM_LIGHT updateAmbientLux: mLightSensorListener lux is 11.0
D/PowerManagerService( 946): Trun on the button and after 2000s,then turn off the button !
I/ActivityManager( 946): START u0 {act=com.google.zxing.client.android.SCAN cat=[android.intent.category.DEFAULT] pkg=com.test.testapp296079 cmp=com.test.testapp296079/com.google.zxing.client.android.CaptureActivity} from uid 10110 on display 0
V/WindowManager( 946): addAppToken: AppWindowToken{2ac1f12b token=Token{2571457a ActivityRecord{1e190da5 u0 com.test.testapp296079/com.google.zxing.client.android.CaptureActivity t35}}} to stack=1 task=35 at 1
V/WindowManager( 946): Adding window Window{2ec02634 u0 com.test.testapp296079/com.google.zxing.client.android.CaptureActivity} at 9 of 13 (after Window{3d1aa37b u0 com.test.testapp296079/com.test.testapp296079.MainActivity})
V/WindowManager( 946): Adding window Window{2c8f09d2 u0 SurfaceView} at 9 of 14 (before Window{2ec02634 u0 com.test.testapp296079/com.google.zxing.client.android.CaptureActivity})
D/AutomaticBrightnessController( 946): ZTE_PM_LIGHT updateAmbientLux: mLightSensorListener lux is 9.0
D/AutomaticBrightnessController( 946): ZTE_PM_LIGHT updateAmbientLux: mLightSensorListener lux is 17.0
D/PowerManagerService( 946): turnOffButtonLight mButtonLightTimeout = 2000
D/AutomaticBrightnessController( 946): ZTE_PM_LIGHT updateAmbientLux: mLightSensorListener lux is 8.0
D/AutomaticBrightnessController( 946): ZTE_PM_LIGHT updateAmbientLux: mLightSensorListener lux is 110.0
D/AutomaticBrightnessController( 946): updateAutoBrightness: value=0.16730924 *255 = 42.663857
D/AutomaticBrightnessController( 946): updateAutoBrightness: mScreenAutoBrightness=21, newScreenAutoBrightness=43
D/DisplayPowerController( 946): ZTE_PM updatePowerState mPowerRequest.dozeScreenState=0
D/DisplayPowerController( 946): ZTE_PM_PROX updatePowerState state=2
D/DisplayPowerController( 946): ZTE_PM_PROX disable ProxSensor while NO useProximitySensor
D/AutomaticBrightnessController( 946): ZTE_PM mScreenAutoBrightnessAdjustment no change
D/AutomaticBrightnessController( 946): shuangdan LightSensorchanged = true,autolcdenable = true,autobuttonEnabled = false
D/AutomaticBrightnessController( 946): updateAutoBrightness: value=0.16730924 *255 = 42.663857
D/DisplayPowerController( 946): ZTE_PM_LHX_animate mPowerState.getScreenBrightness() 21 mPowerState.getActualScreenBrightness() 21
D/DisplayPowerController( 946): ZTE_PM_animate animate LCD brightness to 43
Turns out a very silly issue that is OS specific caused it to fail. iOS handles false as a 0 and android as a text string false. I just had to put this condition and it worked.
if($scope.cancelled === 0 || $scope.cancelled === false)
Thanks @sbasi5576 for sharing your solution.
Can't you change it to simply if(!$scope.cancelled)? Because 0 and false are both falsey.
Note you're speaking of a "text string false" but your code shows a simple false (e.g. the Javascript keyword). The text string false, e.g. "false" or 'false' is NOT falsey.
if (!'false') {
alert('This alert is never shown');
}
This thread has been automatically locked.