I'm trying to read a QR code that appears on the device screen but I cannot find any library that does it without taking a screenshot first.
I know that using zxing
it is possible to scan the QR code from an image, but is there any way to do the scan on runtime when the QR code appears in the device screen?
Asked
Active
Viewed 2,982 times
0

user19922
- 175
- 1
- 3
- 12
-
1Can you generate the image programmatically then send it to zxing? https://stackoverflow.com/questions/2661536/how-to-programmatically-take-a-screenshot-in-android – RobVoisey Jul 25 '17 at 09:18
3 Answers
2
You might try Google's Mobile Vision API.
The detect method only requires a Frame, which you can build from a Bitmap.

Cachapa
- 1,761
- 1
- 15
- 16
1
Consider generating the screenshot programmatically (https://stackoverflow.com/a/5651242/1240523), loading the image as a bitmap and using that in conjunction with zxing.

RobVoisey
- 1,083
- 15
- 24
0
There's a project which allows this called Zxing Android Embedded. Take a look at the Embedding documentation.
There's also an Activity which they provide as a sample using their DecoratedBarcodeView
.
It's embedded, and can be added in the XML as shown here, namely:
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:id="@+id/barcode_scanner"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_above="@+id/buttonsLayout"
android:layout_alignParentTop="true">

bkach
- 1,431
- 1
- 15
- 24