Skip to content

HUAWEI Ads SDK sample code. HUAWEI Ads SDK provides the banner, native, rewarded, interstitial and splash ad formats for integration.

License

Notifications You must be signed in to change notification settings

HMS-Core/hms-ads-demo-java

Repository files navigation

Petal Ads Sample Code (Java)

English | 中文

Contents

Introduction

The Java sample code provided by Ads Kit describes how to display ads by integrating the Petal Ads SDK into your Android app.

Installation

Install the sample code on a Huawei phone.
You can use HMS Toolkit to quickly run the sample code. HMS Toolkit supports one-stop kit integration, and provides functions such as free app debugging on remote real devices. To learn more about HMS Toolkit, please refer to the HMS Toolkit documentation.

Configuration Management

N/A

Environment Requirements

Your Huawei phone has HMS Core (APK) 4.0.0 or later installed.

Sample Code

The Java sample code provided by Ads Kit integrates the Petal Ads SDK, which offers a range of ad formats including banner, native, rewarded, interstitial, splash, and roll ads. The sample code contains the following files for you to load and display ads and obtain user consent:

(1) BannerActivity.java Used to load and display banner ads.
Storage path: app\src\main\java\com\huawei\hms\ads\sdk\BannerActivity.java

(2) NativeActivity.java Used to load and display native ads.
Storage path: app\src\main\java\com\huawei\hms\ads\sdk\NativeActivity.java

(3) RewardActivity.java Used to load and display rewarded ads.
Storage path: app\src\main\java\com\huawei\hms\ads\sdk\RewardActivity.java

(4) InterstitialActivity.java Used to load and display interstitial ads.
Storage path: app\src\main\java\com\huawei\hms\ads\sdk\InterstitialActivity.java

(5) SplashActivity.java Used to load and display splash ads.
Storage path: app\src\main\java\com\huawei\hms\ads\sdk\SplashActivity.java

(6) InstreamActivity.java Used to load and display roll ads.
Storage path: app\src\main\java\com\huawei\hms\ads\sdk\InstreamActivity.java

(7) ConsentActivity.java Used to obtain user consent.
Storage path: app\src\main\java\com\huawei\hms\ads\sdk\ConsentActivity.java

(8) ProtocolActivity.java Used to obtain users' consent on the privacy statement.
Storage path: app\src\main\java\com\huawei\hms\ads\sdk\ProtocolActivity.java

Running Result

Banner ads         Interstitial ads        Native ads

Reward ads         Roll ads        Splash ads

Technical Support

You can visit the Reddit community to obtain the latest information about HMS Core and communicate with other developers.

If you have any questions about the sample code, try the following:

  • Visit Stack Overflow, submit your questions, and tag them with huawei-mobile-services. Huawei experts will answer your questions.
  • Visit the HMS Core section in the HUAWEI Developer Forum and communicate with other developers.

If you encounter any issues when using the sample code, submit your issues or submit a pull request.

License

The sample code is licensed under Apache License 2.0.