Banner ads refer to a standard advertising format that occupies a designated space within an app's layout, usually positioned either at the top or bottom of the device screen.
[Important Note]: At present, Pangle supports only two specific banner ad sizes for traffic outside of the Chinese Mainland, namely 300x250(dp) and 320x50(dp). It is crucial to ensure that the banner ad placement and size comply with Pangle's specific requirements to ensure optimal ad performance and user experience.
Furthermore, it is worth noting that after version 46, Pangle will not support a client SDK-based refresh interval. As such, it is recommended to stay up-to-date with the latest versions of Pangle and make the necessary adjustments to ensure continued support and optimal ad performance.
Create an app and banner ad placement on the Pangle platform
Loading an ad is accomplished using the load()
method in the PAGBannerAd
class. The load()
method requires an ad slot id, instance objects of PAGBannerSize
and PAGBannerRequest
, and a PAGBannerAdLoadListener
to be notified when ad loading succeeds or fails. The loaded PAGBannerAd
object is provided as a parameter in the success callback.
PAGBannerRequest is an Ad Loading Manager. It is recommended to be the member variable of the Activity.
PAGBannerAdLoadListener
callbackUse the method of PAGBannerAd to load the ad, and register the PAGBannerAdLoadListener callback.
Note
Only Google bidding and Google AdMob, and Google Ad Manager support adaptive banners. Adaptive Banners and Inline adaptive banners are supported starting with Pangle sdk version 7.1.0.0.
Google recommends that developers include a 50px padding between the banner placement and the app content. This makes it less likely that users will accidentally click on the banner. Refer to Google’s “About Confirmed Click” policy for more information and best practices.
Adaptive banners are responsive banners with heights that derive from the device type and the width of the banner. You integrate adaptive banners in a similar way to how you integrate regular banners.The width passed in cannot exceed the screen width.
Return value | api | description |
PAGBannerSize | getCurrentOrientationAnchoredAdaptiveBannerAdSize(Context context, int width) | Returns a PAGBannerSize suitable for small banners, with the specified width and a height generated based on the current screen orientation, maintaining a similar aspect ratio to PAGBannerSize. The height will never exceed 15% of the device's current orientation height and will never be less than 50dp. For any width/device combination, this function always returns the same height. If the context is null or the device height cannot be determined from the context, the returned PAGBannerSize width and height will be -1. |
Adaptive banners are anchored by default. Alternatively, you can enable inline adaptive banners, which are meant to appear in scrolling content. Inline adaptive banners are typically larger and taller than anchored adaptive banners. They have variable heights that can extend to the full height of the device screen.
Return value | api | description |
PAGBannerSize | getCurrentOrientationInlineAdaptiveBannerAdSize(Context context, int width) | Returns a PAGBannerSize with the specified width and a height of 0. The Pangle server will select the optimal ad size, with the height not exceeding the screen height. The actual ad size can be obtained by calling PAGBannerAd.getBannerSize() in the PAGBannerAdLoadListener.onAdLoaded callback. If the context is null or the device height cannot be determined from the context, the returned PAGBannerSize width and height will be -1. |
PAGBannerSize | getInlineAdaptiveBannerAdSize(int width, int maxHeight) | Returns a PAGBannerSize with the specified width and a height of 0. The Pangle server will select the optimal ad size with a height not exceeding the maximum height specified in the maxHeight parameter. The actual ad size can be obtained by calling PAGBannerAd.getBannerSize() in the PAGBannerAdLoadListener.onAdLoaded callback. |
PAGBannerAdLoadListener
callbackPAGBannerAdLoadListener | description |
onError | This method is invoked when an ad fails to load. It includes an error parameter of type Error that indicates what type of failure occurred. For more information, refer to the ErrorCode section |
onAdLoaded | This method is executed when an ad material is loaded successfully. |
Ad event callbacks need to be registered before displaying an ad. Each method in the event callback corresponds to an event in the ad lifecycle.
PAGBannerAdInteractionListener | description |
onAdShowed | This method is invoked when the ad is displayed, covering the device's screen. |
onAdClicked | This method is invoked when the ad is clicked by the user. |
onAdDismissed | This method is invoked when the ad disappears. |
After the advertisement is loaded successfully, an instance of the PAGBannerAd
object is returned. Call the getBannerView
of the PAGBannerAd
object to obtain the View of the Banner advertisement. After adding BannerView to the ViewContainer (such as FrameLayout), the advertisement can be displayed automatically.
When destroying the ad, call destroy()
of PAGBannerAd. This method needs to be called on the main thread.
Upon completing the integration, it is essential to ensure that you test your app functionality prior to launching it to end users. It is highly recommended that you employ test ads rather than live ads.
To facilitate the testing process, Pangle offers a "test mode" that is specifically designed to generate test ads for every request. You can seamlessly implement this mode in your app during the coding, testing, and debugging phase, and gain confidence that your app's ad functionality is fully operational before deploying it to end users.
Refer to the How to add a test device? to add your device to the test devices on the Pangle platform.