12

I am currently researching to build an alarm clock application in Android. I am utterly and completely new to programming with QR codes. I know nothing about it. But right now, I want to find out the feasibility of creating an application with QR code functionality. (I have two weeks to build this)

My first question is: would I have to handle the camera myself in the code i.e. do I have to fire it up and then close it and then process the QR image?

2nd Q: How would I create the QR code and then when I scan it, how does it know it scanned the right one? I want to print one, place it in the kitchen or bathroom and then when the alarm goes off, I have to scan the code before the alarm turns off.

4

2 回答 2

16

在 Android 中,这需要大约 10 分钟:

https://github.com/zxing/zxing/wiki/Scanning-Via-Intent

于 2013-04-18T11:47:56.797 回答
7

只需下载条形码扫描仪 (QR-Code Scanner) apk 文件。

http://www.aapktop.com/tag/barcode-scanner-apk http://www.4shared.com/android/2lwrpeHZ/Barcode_Scanner.html http://code.google.com/p/zxing/downloads/ detail?name=BarcodeScanner4.31.apk

将其安装在您的设备上(不在模拟器上)。

现在按照这些步骤。

  1. 创建一个新项目
  2. 在您的 XML 文件中放置一个按钮。
  3. 为它创建一个点击事件并通过意图调用(QR-Code Scanner)作为

            // Scan Handler
    btnScan.setOnClickListener(new OnClickListener() {
    
        @Override
        public void onClick(View v) {
    
            Intent intent = new Intent(
                    "com.google.zxing.client.android.SCAN");
            intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
            startActivityForResult(intent, 0);
        }
    });
    
  4. 将 onActivityResult 方法重写为

    // ZXing Result Handler
    
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
    
    
                contents = intent.getStringExtra("SCAN_RESULT"); // This will contain your scan result
                    String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
    
    
        }
     }
    

第二季度

Answer

那里有很多链接,您可以自由生成任何类型的二维码。只需谷歌它“在线二维码生成器” http://qrcode.kaywa.com/

于 2013-04-18T12:10:21.973 回答