ekreutz / react-native-barcode-scanner-google

Barcode scanner for react native, which implements barcode detection from Google's Vision API.
MIT License
113 stars 68 forks source link

How to close the camera after reading the barcode in android? #16

Closed Aravindhan12 closed 6 years ago

Aravindhan12 commented 6 years ago

I was able to read the barcode successfully. But how can I close the camera after reading the barcode ?

romanenko commented 6 years ago

I'd suggest you to use some kind of navigation library, like, for example ReactNavigation. Use scanner on one screen and just navigate away from it, by pushing new screen to the stack.

Simpler approach would be to keep state in component, where you intent to use this scanner. And, when onBarcodeRead you should pauseScanner (See instructions here) and setState() to some value, to render something, for example, on top of everything

3lhagvaasuren commented 6 years ago

@Aravindhan12 can you post the implementation? That could help me. My code is not working. And can you please post your package.JSON?

ekreutz commented 6 years ago

@romanenko thanks for the answer. In short, use the following approaches:

  1. Navigate away from the scanner view
  2. [advanced] Manage the scanning state using pauseScanner() and startScanner()