catch and show exceptions thrown at printing

This commit is contained in:
tibbi 2023-02-28 15:44:22 +01:00
parent 71da396e08
commit 4ebf1f4a4a

View File

@ -1169,7 +1169,11 @@ class MainActivity : SimpleActivity() {
val printAdapter = webView.createPrintDocumentAdapter(jobName)
(getSystemService(Context.PRINT_SERVICE) as? PrintManager)?.apply {
print(jobName, printAdapter, PrintAttributes.Builder().build())
try {
print(jobName, printAdapter, PrintAttributes.Builder().build())
} catch (e: IllegalStateException) {
showErrorToast(e)
}
}
}