如何在 Android 上注册我的应用程序来处理“类型”二维码?
Android 上的内置条形码扫描仪应用程序(我认为是基于 zxing)读取 QR 码,并将该数据启动到基于前导文本的应用程序中。例如,“BEGIN:VCAL”可能会启动日历应用程序; “http:”可能会启动浏览器。
如何“注册”我的应用程序,以便操作系统(或条形码应用程序)针对特定类型(即前导字符)的 QR 码文本调用它?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
上面的评论大部分是正确的。但是,该应用程序不会在内部处理任何操作。最后,它会为所有操作触发某种 Intent,例如添加联系人、打开 URL、添加日历事件。通过注册来处理那些 Intents,您可以以正常方式 (AndroidManifest.xml) 向 Android 注册来处理这些操作。
如果它是非常自定义的东西,也许可以为其定义一个新的 URL 方案,例如“foobar:/...”。然后在AndroidManifest.xml中注册处理此类URI以获得相同的效果。
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.
据我所知,至少对于 ZXing 的条码扫描仪来说,你不知道。
ResultHandler
类的名册及其到给定前缀的映射被硬编码在ResultHandlerFactory
和ParsedResultType
。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 inResultHandlerFactory
andParsedResultType
.