kaneda
kaneda

Reputation: 6187

Loading a url from WebView without showing it

Is it possible to load a url from a WebView without having it attached to any layout (not visible)?

Upvotes: 5

Views: 3077

Answers (1)

TacB0sS
TacB0sS

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

Related Questions