question

Alan avatar image
Alan asked ·

Barcode Scanner And Intents

Hi DevAsk, Is it possible to register a barcode receiver similar to how the AppNotificationReceiver works?

I'm looking to allow a merchant to scan a barcode from anywhere (especially from outside of my own app), and receive the barcode in a BroadcastReceiver similar to how the AppNotificationReceiver works. My goal is to process the scanned barcode and do some network calls in the background, to allow merchants to remain in their 'register' app to avoid disrupting their flow with their physical customers.

Is that currently possible or do I need to trigger the BarcodeScanner from my own app?

I've been referencing the example applications but can only find examples of apps that trigger the scanner themselves. Best regards, Alan

Intents
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Jeffrey Blattman avatar image
Jeffrey Blattman answered ·

Yes you can simply listen for the broadcast and do some work. And yes, you should do that work in the background so as to not interrupt the merchant's flow in the foreground app.

4 comments Share
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks Jeff!

0 Likes 0 · ·

Hi @jeff From other recent answers here and here it sounds like this is no longer supported?

I'm looking to avoid forcing merchants to return to my app by utilising the scanner when they may be in the register app or elsewhere. If the scanner can no longer be used, do you have any suggestions? Thanks

0 Likes 0 · ·

Hi @russ-eaton It sounds like you were trying to do something similar to me here. Have you found a workaround since?

0 Likes 0 · ·

In the previous answer, I said that you cannot (and have never been able to) "intercept" the scanner broadcast from getting to Register and handle it in an app-specific way. You can still receive the broadcast, you just can't keep Register (or any other app) from receiving it.

0 Likes 0 · ·

Welcome to the
Clover Developer Community