嗨如何获取扫描图像是条形码还是QR?这是我的代码,我只能获得产品ID,但我无法获得扫描格式名称。怎么解决这个问题。请我解决这个问题。
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import com.contus.sportscorner.utils.Constants;
import com.google.zxing.Result;
import com.google.zxing.client.android.CaptureActivity;
public class ScannerActivity extends CaptureActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.barcode_scan);
}
@Override
public void handleDecode(Result rawResult, Bitmap barcode) {
String productId = rawResult.getText();
Intent intent = new Intent(ScannerActivity.this, NextAcitivity.class);
intent.putExtra(Constants.ID, productId); // i am getting just product
// id
startActivity(intent);
finish();
}
}
答案 0 :(得分:2)
使用此功能。
String barcodeType = rawResult.getBarcodeFormat()。toString();
答案 1 :(得分:0)
首先你应该转换成字符串然后比较这些值
how to convert in to string