1

我正在尝试创建一个 android 应用程序,我需要读取 QR 码并将其发送到其余服务。我已成功读取二维码 - 感谢 Zxing。然后我需要将它存储在一个变量中(如何?)并将其发送到其余服务。我需要使用 Zxing 的解码器包吗?你能给我一些见解吗?这是我的代码的相关部分:

public void onClick(View v) {
                // TODO Auto-generated method stub
   Intent intent = new Intent("com.google.zxing.client.android.SCAN");
   intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "QR_CODE_MODE");
   startActivityForResult(intent, 0);
}

if (resultCode == RESULT_OK)
        {
             // Handle successful scan
            String contents = intent.getStringExtra("SCAN_RESULT");
            String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
            Log.i("xZing", "contents: "+contents+" format: "+format);

            LayoutInflater layoutInflater = LayoutInflater.from(context);
            View promptView = layoutInflater.inflate(R.layout.enter_bill, null);

            TextView errorText = (TextView)findViewById(R.id.errorMessage);
            EditText payment = (EditText) findViewById(R.id.amount);
            String amount = payment.getText().toString();

            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);

            try{

               //I should call rest here.

            }catch(Exception e) {
                e.printStackTrace();
                errorText.setText("ERROR!");    
            }
        } 

 else if (resultCode == RESULT_CANCELED)
        {
            // Handle cancel
            Log.i("xZing", "Cancelled");
        }    

谢谢...

4

0 回答 0