Is this possible to do with inline java? My Java skill are pretty lacking.
Source: https://developers.google.com/ml-kit/vision/doc-scanner/android#java
Source: https://developers.google.com/ml-kit/vision/doc-scanner/android#java
Java:
GmsDocumentScanner scanner = GmsDocumentScanning.getClient(options);
ActivityResultLauncher<IntentSenderRequest> scannerLauncher =
registerForActivityResult(
new StartIntentSenderForResult(),
result -> {
if (result.getResultCode() == RESULT_OK) {
GmsDocumentScanningResult result = GmsDocumentScanningResult.fromActivityResultIntent(result.getData());
for (Page page : result.getPages()) {
Uri imageUri = pages.get(0).getImageUri();
}
Pdf pdf = result.getPdf();
Uri pdfUri = pdf.getUri();
int pageCount = pdf.getPageCount();
}
});
scanner.getStartScanIntent(activity)
.addOnSuccessListener(intentSender ->
scannerLauncher.launch(new IntentSenderRequest.Builder(intentSender).build()))
.addOnFailureListener(...);