条码扫描仪outpan数据库(Barcode scanner with outpan databas

2019-10-20 17:30发布

我想开发在android系统条形码扫描应用程序,我尝试使用斑马线库。 斑马线扫描器读取条码非常好,然后要求用户进行网络搜索或产品搜索直通谷歌和谷歌显示的结果。 下面是我在做什么到现在:

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;

public class ScanCodeActivity extends Activity {

    private Button scan;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.scancodelayout);

        scan= (Button)findViewById(R.id.scan_button);

        Button scanBtn  = (Button)findViewById(R.id.scan_button);
        final TextView  formatTxt = (TextView)findViewById(R.id.scan_format);
        final TextView contentTxt = (TextView)findViewById(R.id.scan_content);

        scanBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                IntentIntegrator scanIntegrator = new IntentIntegrator(ScanCodeActivity.this);
                scanIntegrator.initiateScan();
            }
        });
    }

    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
           if (requestCode == 0) {
               IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
               if (resultCode == RESULT_OK) {
                   if (scanningResult != null) {
                       final TextView  formatTxt = (TextView)findViewById(R.id.scan_format);
                       final TextView contentTxt = (TextView)findViewById(R.id.scan_content);
                       String scanContent = scanningResult.getContents();
                       String scanFormat = scanningResult.getFormatName();
                       Toast toast = Toast.makeText(this, "Content:" + scanContent + " Format:" + scanFormat , Toast.LENGTH_LONG);

                       formatTxt.setText("FORMAT: " + scanFormat);
                       contentTxt.setText("CONTENT: " + scanContent);
                     //we have a result
                     }
                   else{
                        Toast toast = Toast.makeText(getApplicationContext(), 
                            "No scan data received!", Toast.LENGTH_SHORT);
                        toast.show();
                    }
               } else if (resultCode == RESULT_CANCELED) {
                  // Handle cancel
                  Log.i("App","Scan unsuccessful");
               }
         }
      }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}

我想实现的是我要查询非商业数据库。 我发现这个链接:

http://www.outpan.com/developers-get-product-data.php

谁能告诉我如何使用它在android系统? 我想扫描特定的代码和查询与它outpan数据库,以便我分析的结果为字符串,在我的Android应用程序显示出来。 用户会知道条形码代表的产品..

文章来源: Barcode scanner with outpan database