views:

27

answers:

2

The built-in barcode scanner application on Android (based, I think, on zxing) reads QR Codes and launches that data into an application based on the leading text. For example, "BEGIN:VCAL" might launch a calendar application; "http:" might launch a browser.

How can I "register" my application so the OS (or the Barcode application) will call it for a specific type (i.e. leading characters) of QR Code text?

+1  A: 

How can I "register" my application so the OS (or the Barcode application) will call it for a specific type (i.e. leading characters) of QR Code text?

At least for ZXing's Barcode Scanner, you don't, near as I can tell. The roster of ResultHandler classes and their mappings to given prefixes is hardcoded in ResultHandlerFactory and ParsedResultType.

CommonsWare
Thank you. This is exactly the information I needed, albeit not as I had hoped.
Richard Haven
+1  A: 

The comment above is mostly correct. However the app does not handle any actions internally. In the end it fires an Intent of some kind for all actions, such as adding a contact, opening a URL, adding a calendar event. By registering to handle those Intents, in the normal way (AndroidManifest.xml) you can register with Android to handle these actions.

If it's something very customized, maybe define a new URL scheme for it like "foobar:/...". Then register to handle such URIs in AndroidManifest.xml to get the same effect.

Sean Owen