Reputation: 6187
Is it possible to load a url from a WebView
without having it attached to any layout (not visible)?
Upvotes: 5
Views: 3077
Reputation: 10266
Yes, you can use your application context to instantiate your WebView:
WebView webView = new WebView(getApplicationContext());
webView.loadUrl("your-url");
Surprisingly this works... which means that a webview can actually be created with the application context and does not need a UI context which for me is a bit weird.
Upvotes: 9