
Building an Android app that wraps a website in a WebView is easy until connectivity disappears. The default behavior of many WebView containers is to show a blank screen or a system error page when the device enters airplane mode. Instead, you can design a remote-to-local toggle that serves cached or bundled content when the network is unavailable.
The core problem with default WebView behavior
Most WebView apps simply load a remote URL. When the network drops, the WebView attempts to fetch the page, fails, and displays an error. For users who expect offline access to guides, reference material, or dashboards, this feels broken. Airplane mode should not mean a dead app.
What a remote-to-local toggle actually does
The idea is simple. The app tries to load the live website. If loading fails or if the device reports no connectivity, the app switches to a local fallback resource stored inside the Android assets folder. This could be a single HTML file, a snapshot of key pages, or a lightweight offline shell that shows a friendly message and cached content.
Detecting connectivity before the WebView loads
Use the Android ConnectivityManager to check whether the network interface is active. Register a network callback to listen for changes. When airplane mode turns on, the callback fires and you can switch the WebView source to your local fallback immediately rather than waiting for a failed request.
Loading local fallback content from assets
Place your offline content in the assets directory. A file such as offline.html can contain inline CSS, cached text, and links to other local assets. Then load it with file:///android_asset/offline.html. Because it is local, the WebView does not need any internet connection.
Adding a manual toggle for users
Some users want control. Add a small floating action button or menu item that lets them tap to switch between remote and local modes. Store their preference in SharedPreferences so the app respects their choice on the next launch. This is the remote-to-local toggle in its most literal form.
Caching the last good remote page
A simple local fallback is useful, but a cached version of the live site is even better. After a successful page load, save the WebView content or relevant data to a local file. When offline, load that saved snapshot. For simple sites with mostly text and images, this creates a surprisingly capable offline reading experience.
Handling airplane mode gracefully after a failed load
Override the WebViewClient onReceivedError method. When an error occurs, call loadUrl on your local fallback instead of letting the default error page appear. This ensures the user never sees a raw network failure. It also keeps the app feeling responsive because the fallback appears instantly.
Testing the toggle on a real device
Emulators can simulate airplane mode, but real device testing reveals edge cases such as slow network transitions or Wi-Fi calling. Turn airplane mode on and off while the app is in the foreground and in the background. Confirm the app switches sources without crashing or losing the user’s scroll position.
When a quick solution is already available
If you want to convert a website into an Android app without writing all this fallback logic yourself, a tool like WebViewGold can handle the WebView wrapper quickly and simply. It provides a ready-made Android project that turns websites into apps easily, giving you a solid base for adding custom remote-to-local behavior without starting from scratch.
Keeping the offline experience intentional
Remote-to-local toggling should never feel like a second-class mode. Design the local fallback with the same visual language as the live site. Include clear offline indicators, preserve navigation where possible, and preload essential content so airplane mode becomes a feature instead of a failure.




