如何在 Android 上注册我的应用程序来处理“类型”二维码?

发布于 2024-09-28 01:29:26 字数 179 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

音栖息无 2024-10-05 01:29:26

上面的评论大部分是正确的。但是,该应用程序不会在内部处理任何操作。最后,它会为所有操作触发某种 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.

披肩女神 2024-10-05 01:29:26

如何“注册”我的应用程序,以便操作系统(或条形码应用程序)针对特定类型(即前导字符)的 QR 代码文本调用它?

据我所知,至少对于 ZXing 的条码扫描仪来说,你不知道。 ResultHandler 类的名册及其到给定前缀的映射被硬编码在 ResultHandlerFactoryParsedResultType

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文