Search code examples
androidbarcode-scanner

Zebra TC25 - how to keep on receiving broadcast intents while on background


Im using Zebra TC25 DWDemo profile for our app, after enabling broadcast intents for bar code reads. all works well when my app is on the foreground and the screen is on. but once i close the screen with the device power button it stops getting broadcasts and the scanning barcode hardware is not responding. (the red laser read lights dont respond to clicks on the side buttons anymore).

I made sure to successfully acquire a partial wake lock (by logging mssgs on logcat while the device screen is off) and have registered a WakeFullBroadcastReceiver for getting the hardware's broadcast intents.

What to do in order to keep the hardware active and getting barcode reads and broadcasts to my app while device's screen is off and the CPU is kept awaken?


Solution

  • The DWDemo app is using DataWedge to capture scan data, specifically the 'DWDemo' profile and you can see this if you go to the settings screen from within the app. DataWedge is a separate service on the device and just because your app has a partial wake lock I'm pretty sure that does not prevent the DataWedge service from still sleeping when the screen turns off, plus you would need to consider other scenarios like the device entering doze mode and clearing existing wake locks. DataWedge is designed primarily to change the scanner configuration when different applications appear in the foreground; when the screen turns off the app goes to the background as far as Android is concerned so DataWedge would also likely switch out of the 'DWDemo' profile anyway.

    For your needs I think it would make more sense to access the scanner directly via the native SDK, EMDK which is available for both Android (Java) and Xamarin. Another future option I notice is Zebra are introducing a 'Wakeup sources' parameter (http://techdocs.zebra.com/mx/powermgr/#wake-up-sources-enabledisable) however that requires MX8.0+ which is not (yet?) available for TC2x since MX8.0+ would require Oreo, based on the naming.

    For clarity, I work for Zebra.