Huawei Ads Integration (Part 1: Banner Ads)

Anil Ghimire
2 min readJan 12, 2021

Time spent on mobile apps is constantly growing which provides an opportunity for mobile app owners to make a profitable app by monetizing it and Ads are the most universal and popular way to monetize. In this article, I will explain Huawei Ads and the steps to integrate them.

Huawei Ads SDK provides an easy interface to integrate Ads in the apps understanding the app developers and UX priorities. Huawei Ads kit provides a range of ad formats.

Integrating the Ads SDK

Before integrating APM SDK, the following preparations should be made:

  • Create a Huawei Developer Account. (link)
  • Set up a project in Android Studio and in the Developer console. (link)

After the basic project setup is done, the following configurations needed to be done to integrate Huawei Ads SDK and plugin.

  • Add Huawei Ads dependency in build.gradle of app module.
implementation 'com.huawei.hms:ads-lite:13.4.36.301'

After this, the project is ready to integrate with Huawei Ads Kit. Below is the code Snippets to different types of Ads integration.

  • Banner Ads

Banner ads are a rectangular image layout that is placed at the top, middle, or bottom of the app page. There are different resolutions of banner ads. Banner ads refresh at the given time interval. The user is directed to the advertiser’s page when clicked.

Standard Banner Ads sizes

The banner view can be added either in the XML layout file or can be created using code.

Creating a banner view using XML layout:

The adId used in this code is a test ad slot ID, it must be changed before releasing the app. The banner size can be selected as per the developer's requirement.

The banner view can be created using the code. The sd slot ID and ad size must be set. The sample code for creating the view and loading the ad is:

The different events of ads can be handled using an AdListener Class. The developer can perform the required action by listening to these events.

Hope you are able to integrate Banner Ads into your application. In my next article, I will explain the integration process of other ad formats.

Happy Monetization using Huawei Ads.

Reference:
https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/publisher-service-banner-0000001050066915

--

--