Skip to main content

(Optional) No Network Connectivity

Add new flag to SFWebViewWidget - shouldCollapseOnError - i.e. height of WebView will collapse to 0 on error

Requirement

The instructions in this document are implemented in Outbrain Android SDK version > 4.21.0 - Please make sure you are using the correct version.

How to use?

Step 1

In the current Activity, add the following lines BEFORE loading (init()) the widget

SFWebViewWidget.shouldCollapseOnError = true;
SFWebViewWidget.setNetworkDelegate(this);
mSFSmartfeedWidget.init(scrollView, "https://mobile-demo.outbrain.com");

Step 2

Implement SFWebViewNetworkDelegate in the current Activity

See example:

@Override
public boolean checkInternetConnection() {
Context context = this.getApplicationContext();
ConnectivityManager con_manager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);

return (con_manager.getActiveNetworkInfo() != null
&& con_manager.getActiveNetworkInfo().isAvailable()
&& con_manager.getActiveNetworkInfo().isConnected());
}