The large layout Ad is mediation of standard units that can be configured from the PubNative dashboard. Large layout ad view contains a predefined set of elements such as icon, banner, title, description, CTA and disclosure view. You can choose a more specific ad type from PubNative's dashboard, clarifying video only, banner only or description-banner-icon etc.
You will get a fully created view in large layout that can be shown on screen using show() method. If you want to remove an ad from the screen or you're exiting the activity, you can use hide() method. By default, the ad is removed from screen instantly when hardware back key pressed on a device.
Getting Started
- Before integrating large ad layouts in to your app, you’ll need to go through the steps in our Getting Started Guide, create an account on the PubNative Dashboard, and integrate the SDK into your project.
- Add a large layout ad unit to your app in the PubNative Dashboard
- Make sure you have added the ad network SDKs you wish to use to your app
Integration
1. Create Layout
You can create a predefined large layout ad request using PNLargeLayout
PNLargeLayout layout = new PNLargeLayout();
2. Integrate Lifecycle Callbacks
You can track the load process, user interaction and ad behavior with callbacks using setLoadListener(<YOUR_LISTENER>) method. You need to set listener as
layout.setLoadListener(new PNLargeLayout.LoadListener() {
@Override
public void onPNLayoutLoadFinish(PNLayout layout) {
// layout returned
}
@Override
public void onPNLayoutLoadFail(PNLayout layout, Exception exception) {
// ad request failed
}
});
You can track the tracking process, user interaction and ad behavior with callbacks using setTrackListener(<YOUR_LISTENER>) method. You need to set listener as
largeLayout.setTrackListener(new PNLargeLayout.TrackListener() {
@Override
public void onPNLayoutTrackImpression(PNLayout layout) {
// ad impression confirmed
}
@Override
public void onPNLayoutTrackClick(PNLayout layout) {
// ad shown on screen
}
});
You can track the view status with callbacks using setViewListener(<YOUR_LISTENER>) method. You need to set listener as
largeLayout.setViewListener(new PNLargeLayout.ViewListener() {
@Override
public void onPNLayoutViewShown(PNLayout layout) {
// ad shown on the screen
}
@Override
public void onPNLayoutViewHidden(PNLayout layout) {
//ad hide from the screen
}
});
3. Load Ad
To load a large layout advertisement
layout.load(<CONTEXT>, "<YOUR_APP_TOKEN_HERE>", "<YOUR_PLACEMENT_NAME_HERE>");
Once an ad is loaded, You will get a fully created view that can be placed in any ViewGroup.
4. Handle the ad
If you didn't implement the callback, additionally, you can also check the load status of the layout with the following method that returns a boolean set to true if the ad is ready to be shown.
largeLayout.isReady()
Once the LoadListener callback is invoked you can show the ad using the show method or hide externally using hide. Expect the user to close the ad by itself unless you have an specific need to hide it. If the ad is not ready any interaction with this method will do nothing
// Use this to show the full screen interstitial
largeLayout.show();
// Use this to hide the full screen interstitial
largeLayout.hide();