我使用新的谷歌播放服务:条码检测仪,这porposue我下面这个教程:https://search-codelabs.appspot.com/codelabs/bar-codesdetector.isOperational()总是假的Android
但是当我运行应用程序在我的真实设备(Asus Nexus 7)上,应用程序的文本视图始终显示“无法设置检测器”,我不知道如何使其工作> < ...
这里一些用于快速调试的代码:
public class DecoderBar extends Activity implements View.OnClickListener{
private TextView txt;
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_decoder);
Button b = (Button) findViewById(R.id.button);
txt = (TextView) findViewById(R.id.txtContent);
img = (ImageView) findViewById(R.id.imgview);
b.setOnClickListener(this);
}
// [...]
@Override
public void onClick(View v) {
Bitmap myBitmap = BitmapFactory.decodeResource(getApplicationContext().getResources(),R.drawable.popi);
img.setImageBitmap(myBitmap);
BarcodeDetector detector = new BarcodeDetector.Builder(getApplicationContext())
.setBarcodeFormats(Barcode.DATA_MATRIX | Barcode.QR_CODE)
.build();
if(!detector.isOperational()){
// Always show this message, so, never is operational!
txt.setText("Could not set up the detector!");
return;
}
Frame frame = new Frame.Builder().setBitmap(myBitmap).build();
SparseArray<Barcode> barcodes = detector.detect(frame);
Barcode thisCode = barcodes.valueAt(0);
txt.setText(thisCode.rawValue);
}
}
我也面临这个问题 - 的Nexus 4 5.1.1的CyanogenMod 12.1和Google Play服务8.3.0。互联网连接不是一个问题(工作和快速),可用的存储也不是,仍然是运算总是错误的。 –