Я использую новый Google играет сервис: детектор штрих-кода, для этого porposue я после этого урока: https://search-codelabs.appspot.com/codelabs/bar-codesdetector.isOperational() всегда ложна на андроид
Но когда я запустить приложение на моем реальном устройстве (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. Интернет-соединение не было проблемой (работающей и быстрой), доступным хранилищем также не было и все еще получено isOperational всегда false. –