QR if语句? [英] QR if statement?

查看:248
本文介绍了QR if语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人已经解决了这个问题。我想扫描从我的Andr​​oid手机QR code,这将最终推出一个Android应用程序。如果应用程序存在,应用程序是用一些独特的信息发布。如果应用程序不存在,它需要用户市场下载应用。可以这样做?

I was wondering if anyone has solved this problem. I want to scan a QR code from my android phone that will ultimately launch an Android App. If the app exists, the app is launched with some unique information. If the app doesn't exist then it takes the user the marketplace to download the app. Can this be done?

任何帮助将大大AP preciated:)

Any help will greatly be appreciated :)

推荐答案

当然,你可以写一个应用程序,可以做到这一点。 酒吧code扫描仪实际上做一些的你想要的东西(例如从code开放市场),这是开源,如果你需要一些样品看一看那里。该项目也有,你可以用它来扫描QR- /酒吧codeS库。

Sure, you can write an app that can do that. Barcode Scanner actually does some of the things you want (e.g. opening the market from a code), it's open source, if you need some samples take a look there. The project also has a library that you can use to scan QR-/barcodes.

在心中的记住,一个QR- code是没有别的比在机器可读格式的字符串。的您可以连接$ C $的Ca一个code包名称和扫描。当你成功地这样做,只是测试是否与包名的应用程序是在设备上present。如果是的话,通过意图(你可以使用<一个运行href=\"http://developer.android.com/reference/android/content/pm/PackageManager.html#getLaunchIntentForPackage%28java.lang.String%29\"相对=nofollow> PackageManager.getLaunchIntentForPackage() 为)的。如果不正确,通过 Intent.ACTION_VIEW 链接到市场页面市场URL。你可以带code一些额外的进QR- codeS,这取决于你选择哪个这些大小。

Keep in mind that a QR-code is nothing else than a String in a machine-readable format. You can encode a package name in a code and scan that. When you successfully did that, just test if the app with that package name is present on the device. If yes, run it via an Intent (you can use PackageManager.getLaunchIntentForPackage() for that). If not, link to the market page via Intent.ACTION_VIEW with a market url. You may encode some extras into the QR-codes, depending on which size you choose for these.

从包名称的好处不仅是有很多codeS已经在那里,链接到一个特定的应用程序在Android Market网站。其格式为:

The benefit from the package name only is that there are many codes already out there that link to the android market site of a certain app. Their format is

market://search?q=pname:com.example

正如你所看到的,已经孤单一个软件包名包括(这里 com。示例)。
可以解析并使用它。如果你想群众演员,你必须设有code你自己qr- codeS虽然。

As you can see, theres already a packagename included (here com.example). You can parse and use it. If you want extras, you have to encode your own qr-codes though.

这篇关于QR if语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆