Skip to content

Commit 17b98b2

Browse files
authored
Update README.md
1 parent a2f7aaa commit 17b98b2

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,60 @@ A Barcode scanning library for Android. Uses the Google Play Services' mobile vi
1010
- `SINGLE_MANUAL`: Detects and highlights all the barcode it can find but returns only the one that user chooses by tapping.
1111
- `MULTIPLE`: Detects and highlights all the barcode it can find. Returns all the barcodes on tap.
1212

13+
###Barcode Types
14+
You can view [this link](https://developers.google.com/vision/barcodes-overview) for a list of supported barcode formats.
1315

16+
###Use the standalone scanner
17+
launch the scanner from your `Activity` like this:
18+
```java
19+
new MVBarcodeScanner.Builder()
20+
.setScanningMode(mMode)
21+
.setFormats(mFormats)
22+
.build()
23+
.launchScanner(this, REQ_CODE);
24+
```
25+
You'll receive the scanned barcode/barcodes in your Activity's `onActivityResult`
26+
```java
27+
if (requestCode == REQ_CODE) {
28+
if (resultCode == RESULT_OK && data != null
29+
&& data.getExtras() != null) {
30+
31+
if (data.getExtras().containsKey(MVBarcodeScanner.BarcodeObject)) {
32+
Barcode mBarcode = data.getParcelableExtra(MVBarcodeScanner.BarcodeObject);
33+
} else if (data.getExtras().containsKey(MVBarcodeScanner.BarcodeObjects)) {
34+
List<Barcode> mBarcodes = data.getParcelableArrayListExtra(MVBarcodeScanner.BarcodeObjects);
35+
}
36+
}
37+
}
38+
```
1439

40+
###Use the scanner fragment
41+
You can use the `BarcodeCaptureFragment` to scan barcodes. Just add the fragment to your `Activity`
42+
```java
43+
MVBarcodeScanner.ScanningMode mode = null;
44+
@MVBarcodeScanner.BarCodeFormat int[] formats = null;
45+
46+
BarcodeCaptureFragment fragment = BarcodeCaptureFragment.instantiate(mode, formats);
47+
getSupportFragmentManager().beginTransaction()
48+
.add(R.id.container, fragment)
49+
.commit();
50+
```
51+
Then make the the `Activity` implement the `BarcodeCaptureFragment.BarcodeScanningListener` so that you can receive results from the fragment or you can set the listener directly to the fragment
52+
```java
53+
fragment.setListener(new BarcodeCaptureFragment.BarcodeScanningListener() {
54+
@Override
55+
public void onBarcodeScanned(Barcode barcode) {
56+
57+
}
58+
59+
@Override
60+
public void onBarcodesScanned(List<Barcode> barcodes) {
61+
62+
}
63+
64+
@Override
65+
public void onBarcodeScanningFailed(String reason) {
66+
67+
}
68+
});
69+
```

0 commit comments

Comments
 (0)