Custom Web View Presentation

By default, Netmera provides a visually appealing user interface for displaying web view content in push/pop-up notification actions. However, if you want to implement your own web view presentation flow, follow these steps:

Step 1: Implement a Receiver Class

Create a class extending NetmeraWebContentBroadcastReceiver and implement its abstract onShow method. Whenever a show web content action occurs, this onShow method will be called. In this method, you should start your flow where web view will be used to show the content. Check code below for sample receiver class.

public class SampleWebContentBroadcastReceiver extends NetmeraWebContentBroadcastReceiver {
  @Override
  public void onShow(Context context, Bundle bundle) {
    //kick your web view flow
  }
  @Override
  public void onClose(Context context, Bundle bundle) {
    //kick your web view is closed
  }
}

Step 2: Add Receiver Class to AndroidManifest

Add created receiver class to your manifest with com.netmera.web.content.SHOW action. Here is the sample,

<application
   >
  ...
  <receiver
    android:name="com.sample.SampleWebContentBroadcastReceiver"
    android:exported="false">
    <intent-filter>
      <action android:name="com.netmera.web.content.SHOW”/>
      <action android:name="com.netmera.web.content.CLOSE"/>
    </intent-filter>
  </receiver>

Step 3: Let Netmera Handle Received Content

Finally, inform Netmera to display the received content in your web view.

//pass your web view as parameter, content will be shown in it
Netmera.handleWebContent(webView);

If you want to listen url loading actions inside your web view, instead of the previous code you should call handle method as follows,

Netmera.handleWebContent(webView, new NetmeraWebViewCallback() {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
                //your implementation here
        //return true if you will handle the url yourself, otherwise return false.
        return false;
      }
    });

Last updated