Search code examples
androidandroid-intentbarcode-scanner

Integrate app with in-built barcode scanner


I am creating an app on an Android tablet that needs to scan barcodes and get the result. The tablet I am using has an in-built scanner, as well as the camera.

I have tried to use the Zxing Lib for this but this uses the camera on the tablet, rather than call the Scanner.

How can I find the actual Intent I need to use to call the Scanner directly from inside my app?

There is a Barcode Utility app pre-installed on the tablet, with a basic screen for capturing barcode data, I think that I probably should call this, via an Intent, in my app. But again how do I know the Intent I need to use to call this utility app?


Solution

  • You may check whether it is a device which has its own barcode scanner by doing something like if (android.os.Build.MANUFACTURER == "Pegatron") { //Do what you are doing now } else { //Use the XZing Intent to provide your service for other devices }

    Of course you have to hardcode all devices with a built-in scanner but I guess there are not many which have such a feature. You could even specify the devices you want to execute their built-in scanner logic by using android.os.Build.MODEL. Check this info page from dev docs for further details.