我想制作一个应用程序作为条形码扫描仪。 我创建了一个名为 android Vision 的条形码扫描仪 api
我可以启动应用程序并将相机放在条形码上。但日志只说:
11-20 11:21:29.353 20243-20243/com.google.android.gms.samples.vision.barcodereader D/Barcode-reader: no barcode detected
谁能告诉我,为什么没有检测到条形码?
最佳答案
Google Vision API 中的barcodeDetector 并不支持所有设备。我遇到了这个问题。当我在 1+ 部手机上尝试时,它在我的手机(华硕)上不起作用,但效果很好。要知道您的手机是否支持它,只需在主要 Activity 的“onCreate”中尝试这段代码即可。
if(!barcodeDetector.isOperational()){
Toast.makeText(getApplicationContext(), "Sorry, Couldn't setup the detector", Toast.LENGTH_LONG).show();
this.finish();
}
如果在您的手机中启动 Activity 之前出现 Toast,则仅意味着您的设备不支持 BarcodeDetector。我猜,这在更高版本的 google play Vision API 中已修复。
尝试使用 Google Play Vision API 9 及更高版本。
关于java - 适用于 Android 的扫描仪(条形码)Api 无法检测到条形码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33826656/