Android · WebView · Open source
Print, downloads and billing in an Android WebView app
Wrap a web app in an Android WebView and three things break straight away: window.print(), file downloads and payments. Why each one fails, how we fixed them, and the open-source library that does it for you.
Techoship LLC · November 24, 2026 · 5 min read
Putting an existing web app inside an Android app is one of the fastest ways onto Google Play. You keep one codebase, ship updates without store review, and the app is live in weeks instead of months.
Then you test it, and three things that work in Chrome do nothing at all:
- The Print button does nothing.
- Export to CSV or Download PDF does nothing either.
- Upgrade to Pro can't take payment, because Google Play wants digital purchases to go through its own billing.
We hit all three when we built Tended Health Pro, a dementia caregiving app whose screens are a web app inside a native Android shell. Here is why each one breaks and how to fix it. The fixes are now an open-source library, linked at the end.
Why a WebView is not a browser
Android's WebView renders pages with the same engine as Chrome, but it leaves the browser around the page to you. In Chrome, printing, the download manager and payments belong to the browser, not the page. In a WebView there is no browser. Anything the page asks the browser to do goes nowhere unless the app handles it.
1. window.print() does nothing
In a WebView, window.print() is a silent no-op: no error, no dialog.
Android can print a WebView's content. WebView.createPrintDocumentAdapter() hands the page to Android's print service, which offers every installed printer and "Save as PDF". What is missing is the connection: the page has to tell the app it wants to print.
The fix: inject a small script that replaces window.print with a message to the app. The app answers by opening the print dialog for the current page. The web app keeps calling window.print() and never knows the difference.
2. Downloads that never arrive
Most web apps create files in the browser. An export builds a CSV in memory, wraps it in a Blob, creates a blob: URL, clicks an invisible link, and revokes the URL on the next line. Chrome saves the file. A WebView calls its DownloadListener with a blob: URL that only exists inside the page. The app can't download it, because there is nothing on a server to fetch.
It gets worse: by the time the app hears about the download, the page has often revoked the URL already.
The fix: read the file in the page, not the app.
- The injected script catches download links as they are clicked, including the invisible ones, and calls
fetch()on theblob:URL straight away. A fetch started before the revoke still gets the file. - It sends the file to the app in chunks of 512 KB, as raw bytes where the WebView supports binary messages and as base64 where it doesn't.
- The app streams the chunks into the shared Downloads folder, through MediaStore on Android 10 and later, so no storage permission is needed.
Ordinary links to files on a server are simpler, but still have a trap: hand the URL to Android's DownloadManager and the download fails if the file needs the user to be signed in, because the session cookie stays behind in the WebView. Copy the WebView's cookies onto the request.
3. Selling through Google Play
If your web app takes card payments through Stripe and the app is on Google Play, digital goods and subscriptions generally have to go through Google Play Billing instead. Billing is a native Android library, and your checkout runs in JavaScript.
The fix: expose Play Billing to the page.
- The page asks for products and their local prices.
- It starts a purchase, and Google Play's own purchase screen opens over the app.
- It gets the result back: purchased, pending, cancelled or already owned.
Two rules matter more than the code:
- Verify on your server. The page receives a purchase token. Send it to your backend, check it with the Google Play Developer API, and only then grant access. A page can be tampered with, so never treat a purchase as real just because JavaScript says so.
- Acknowledge within three days. Play automatically refunds purchases that are never acknowledged. Once your server has granted the purchase, acknowledge it, or consume it if it is a consumable such as credits.
Don't open the whole app to every page
The classic way to connect a page to an app is addJavascriptInterface. It exposes your native methods to every page the WebView loads, including a page the user follows a link to. That is a poor place to put a purchase button.
The modern API, WebViewCompat.addWebMessageListener, takes a list of allowed origins. Pages from your domain get the bridge, and pages from anywhere else never see it. We also only allow purchases from the top-level page, never from an embedded frame, and cap the size of every file a page can save.
The library
We have released all of this as [Android WebView Bridge](https://github.com/Techoship/android-webview-bridge), MIT licensed:
```kotlin val bridge = WebViewBridge.Builder(webView) .allowOrigin("https://app.example.com") .install() BillingBridge.install(bridge, activity) // only if you sell through Play ```
Printing and downloads need no changes to the web app. Billing appears in the page as window.AndroidBilling, with TypeScript types included.
The library is tested on a real Android 16 device image. The tests cover:
- a blob link revoked straight after the click;
- a 3 MB file checked byte for byte;
- the base64 fallback;
- pages from another origin getting nothing.
When a WebView app is the right call
A web app in an Android shell is a good fit when the product is mostly forms, content and dashboards, and when you want one team shipping to web and Android. It is a poor fit when the product depends on heavy animation, a lot of offline work, or hardware such as Bluetooth and the camera, where native or Flutter earns its cost. We wrote about that trade-off in Flutter or native.
If you have a web app and want it on Google Play, with printing, downloads and payments working on day one, that's a project we can scope and quote.
Planning something similar?
A free consultation, then a written plan and a fixed quote.