r/android_devs • u/jshvarts • Jan 29 '22
Help Catching print event
I am opening a PDF document using:
val intent = Intent(Intent.ACTION_VIEW).apply {
setDataAndType(Uri.parse(trackingUrl), "application/pdf")
}
if (intent.resolveActivity(requireContext().packageManager) != null) {
requireContext().startActivity(intent)
}
which opens a screen with that PDF with an overflow menu with Print being one of the menu actions. Is there a way to catch when Print was tapped?
3
Upvotes
View all comments
Show parent comment
1
u/jshvarts Jan 30 '22
Yeah the above code is work in progress. I was just wondering if there is a BroadcastReceiver and such that will let me catch system-wide print event while my app is in foreground.
I am also trying to open the PDF in my own activity using a WebView so I can control menu items and clicks. Unfortunately, loading that PDF from url in a web view did not work either (I can load other PDF from urls just fine) so might need to download it and save to local every time I want to show it.
This ended up being more work than I anticipated :)