Reputation: 41
I am trying to implement the second part of the tutorial in this link:
http://code.tutsplus.com/tutorials/reading-qr-codes-using-the-mobile-vision-api--cms-24680
I am getting the error:
BarcodeDetector has private access at..
Any idea why?
public class ScanActivity extends Activity {
SurfaceView cameraView;
TextView barCodeInfo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scan);
cameraView = (SurfaceView) findViewById(R.id.camera_view);
barCodeInfo = (TextView) findViewById(R.id.code_info);
BarcodeDetector barcodeDetector = new BarcodeDetector().Builder(this).setBarcodeFormats(Barcode.QR_CODE)
.build();
}
}
Upvotes: 2
Views: 1041
Reputation: 4152
The problem is that you are trying to access BarcodeDetector and its constructor is private BarcodeDetector(). BarcodeDetector uses Builder Pattern.
"Builder pattern builds a complex object using simple objects and using a step by step approach." http://www.tutorialspoint.com/design_pattern/builder_pattern.htm
so change to the code below :
BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(this).setBarcodeFormats(Barcode.QR_CODE)
.build();
Upvotes: 6