我使用新的谷歌播放服務:條碼檢測儀,這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。互聯網連接不是一個問題(工作和快速),可用的存儲也不是,仍然是運算總是錯誤的。 –