update history:
Version | Author | Date | Description |
---|---|---|---|
v1.1.4 | heyy | 2019-07-19 | 1. ; |
I. Introduction
This SDK is applied to accessing the advertisement monetizing platform in China, and ensures high efficiency and low maintenance cost with simple procedures to use the advertisement platform and its integrated analysis tools.
II. Preparation
- Download Hippo_SDK.zip file for HippoSDK:
- Acquire the following configuration file from Hippo operational staff:
hippo-ads-config.json.It contains information including those related to advertisement. Please do not modify it.
- Hippo-SDK has already included the Chinese SDK of Umeng. If the developer has used Umeng SDK before and encounters jar conflict, please delete umeng-analytics-xxx.jar and umeng-common-xxx.jar from your Umeng Analytics.
III. Procedures
- Import aar package of HippoSDK
Import all the aar packages downloaded into the Android Project and add dependency;
- Import SDK configuration file
Import hippo-ads-config.json into the following directory under the Android project ( Create the ASSETS folder if it’s not there. Do not modify the name of the json file):
src/main/assets/hippo-ads-config.json
IV. Instructions on using the SDK
Hippo-Ad-SDK
1. Initialize SDK
HippoAdSdk.init(Context);
2. Set ad event listener
HippoAdSdk.setAdsListener(new HippoAdsListener());
public class HippoAdsListener implements IAdsListener {
@Override
public void hippoAdsLoaded(String hippoAdsId, String adsType) {
Log.d("hippo_sdk", "MainActivity adsType:" + adsType + " Successfully loaded");
}
@Override
public void hippoAdsShown(String hippoAdsId, String adsType) {
Log.d("hippo_sdk", "MainActivity adsType:" + adsType + " Successfully shown");
}
@Override
public void hippoAdsClicked(String hippoAdsId, String adsType) {
Log.d("hippo_sdk", "MainActivity adsType:" + adsType + " Successfully clicked");
}
@Override
public void hippoAdsClosed(String hippoAdsId, String adsType) {
Log.d("hippo_sdk", "MainActivity adsType:" + adsType + " Successfully closed");
}
@Override
public void hippoAdsVideoComplete(String hippoAdsId, String adsType) {
Log.d("hippo_sdk", "MainActivity adsType:" + adsType + " Reward");
}
@Override
public void hippoAdsError(String hippoAdsId, String adsType, int code, String message) {
Log.d("hippo_sdk", "MainActivity adsType:" + adsType + " Loading failed errCode:" + code + ", message:" + message);
}
}
3. Load ads
// Load reward video ads
HippoAdSdk.loadRewardVideoAds(string adUnitId);
// Load full-screen video ads
HippoAdSdk.loadFullScreenVideoAds(string adUnitId);
// Load banner ads
// various dimensions of banner adds are supported:600*300,600*400,600*500,600*260,600*90,600*150,640*100,690*388
HippoAdSdk.loadBannerAds(String hippoAdsId, int width, int height);
// Load Interstitial ads
HippoAdSdk.loadInterstitialAds(String hippoAdsId);
Notice: Only one load upon using is needed. The loaded ads will be automatically re-loaded once shown. It’s not necessary to repeatedly call the loading method.
4. Show ads
// Better see whether ads are loaded in advance
HippoAdSDK.isLoaded( string adUnitId );
// Show reward video ads
HippoAdSdk.showRewardVideoAds(string adUnitId, Context context);
// Show full-screen video ads
HippoAdSdk.showFullScreenVideoAds(string adUnitId, Context context);
// Show banner ads
// Currently only supports showing banners ads on top(BannerPosition.TOP)or at the bottom(BannerPosition.BOTTOM)
HippoAdSdk.showBannerAds(Activity context, String adUnitId, BannerPosition position);
// Show interstitial ads
HippoAdSdk.showInterstitialAds(String hippoAdsId, Activity context);
5. Data statistics (required)
Our corresponding APIs should be called in the life cycle method of each Activity: call HippoAdSdk.onAppResume(activity) in onResume() of Activity, call HippoAdSdk.onAppPause(activity) in onPause() of Activity, and call the corresponding function at entering / exiting every page if not Android Native Development is used, for example:
public class MainActivity extends AppCompatActivity {
…………
@Override
protected void onResume() {
super.onResume();
HippoAdSdk.onAppResume(this);
}
@Override
protected void onPause() {
super.onPause();
HippoAdSdk.onAppPause(this);
}
…………
}
6. Umeng custom events
This SDK supports the custom events of Umeng Statistics. Calling method is:
/**
* context:the context of current state
* event:name of the event(in line with the naming of Umeng Statistics event)
* map:including the property of the reported event
*/
HippoReport.sendCustomEvent(Context context, String event, Map<String, String> map)
Hippo-Recorder-SDK (optional)
1. Initialize recorder SDK
HippoAdSdk.initRecorder(this, new IRecordListener() {
@Override
public void onEveryplayShown() {
}
@Override
public void onEveryplayHidden() {
}
@Override
public void onEveryplayReadyForRecording(int resultCode) {
// Recording is ready if resultCode is 1
}
@Override
public void onEveryplayRecordingStarted() {
// Recording starts
}
@Override
public void onEveryplayRecordingStopped() {
// Recording stops
}
@Override
public void onEveryplayThumbnailReadyAtTextureId(int i, int i1) {
}
@Override
public void onFileReady(String videoPath) {
// Go back to the directory of the video when recording stops
}
});
2. Start and stop recording
// Start recording
HippoAdSdk.startRecorder();
// Stop recording
HippoAdSdk.stopRecorder();
Hippo-Share-SDK (optional)
1. Calling method
// See whether certain platform is supported to share to
HippoAdSdk.isSupported(Context context, SharePlatform platform);
// Config sharing content
ShareContentInfo shareContentInfo = new ShareContentInfo();
// Config saving directory of the video to share
shareContentInfo.setFilePath(mRecordVideoPath);
/**
* SharePlatform: platform to share to
* ShareType: type of the content to share
* ShareContentInfo: content to share
* shareHandler: related to callback(need setBackClassName to set the full directory (under the Package name) of the Activity of Interface back from sharing, setListener set the callback)
*/
HippoAdSdk.share(Activity activity, SharePlatform platform, ShareType type, ShareContentInfo shareContentInfo, HPShareHandler shareHandler);
V. Obfuscation
No obfuscation is set in this SDK. If the accessed project has enabled obfuscation, please config the following codes into the obfuscation file:
# hippo-sdk(required)
-keep class com.hippo.ads.**{*;}
-keep class com.hippo.ads.**
-dontwarn com.hippo.ads.**
-keeppackagenames com.hippo.ads.**
# jrtt-sdk(required)
-keep class com.bytedance.sdk.openadsdk.** { *; }
-keep public interface com.bytedance.sdk.openadsdk.downloadnew.** {*;}
-keep class com.androidquery.** {*;}
-keep class com.androidquery.**
-dontwarn com.androidquery.**
-keeppackagenames com.androidquery.**
-keep class com.ss.android.**{*;}
-keep class com.ss.android.**
-dontwarn com.ss.android.**
-keeppackagenames com.ss.android.**
# umeng-sdk(required)
-keep class com.umeng.commonsdk.**{*;}
-keep class com.umeng.commonsdk.**
-dontwarn com.umeng.commonsdk.**
-keeppackagenames com.umeng.commonsdk.**
# recorder-sdk(required if accessed)
-keep class com.everyplay.Everyplay.**{*;}
-keep class com.everyplay.Everyplay.**
-dontwarn com.everyplay.Everyplay.**
-keeppackagenames com.everyplay.Everyplay.**
VI. Troubleshooting
1. If errors such as certain methods missing arereported, please config like the following:
Two places in build.gradle need configuration:
Config merging method
android { ... defaultConfig { ... multiDexEnabled true ... } ... }
Add dependency
implementation 'com.android.support:appcompat-v7:28.0.0'