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(...);