How can I register my application on Android to handle a "type" of QR Code ?
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 bro开发者_JAVA技巧wser.
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?
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.
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
.
精彩评论