# hms-ads-demo-java **Repository Path**: hms-core/hms-ads-demo-java ## Basic Information - **Project Name**: hms-ads-demo-java - **Description**: 华为广告服务流量变现服务为您提供了Banner广告、原生广告、激励广告、插屏广告、开屏广告、贴片广告六种广告形式。此工程指导如何将HUAWEI Ads SDK集成到您的Android应用中。 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/publisher-service-introduction-0000001070671805 - **GVP Project**: No ## Statistics - **Stars**: 12 - **Forks**: 6 - **Created**: 2021-02-19 - **Last Updated**: 2025-07-21 ## Categories & Tags **Categories**: hms **Tags**: None ## README # Petal Ads Sample Code (Java) English | [中文](https://github.com/HMS-Core/hms-ads-demo-java/blob/master/README_ZH.md) ## Contents * [Introduction](#Introduction) * [Installation](#Installation) * [Configuration](#Configuration) * [Environment Requirements](#Environment-Requirements) * [Sample Code](#Sample-Code) * [Running Result](#Running-Result) * [License](#License) ## 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](https://developer.huawei.com/consumer/en/doc/development/Tools-Guides/getting-started-0000001077381096?ha_source=hms1).
## 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](https://www.reddit.com/r/HuaweiDevelopers/) 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](https://stackoverflow.com/questions/tagged/huawei-mobile-services?tab=Votes), 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](https://forums.developer.huawei.com/forumPortal/en/home?fid=0101187876626530001?ha_source=hms1) and communicate with other developers. If you encounter any issues when using the sample code, submit your [issues](https://github.com/HMS-Core/hms-ads-demo-java/issues) or submit a [pull request](https://github.com/HMS-Core/hms-ads-demo-java/pulls). ## License The sample code is licensed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).