Video Ads Integration For Android english - Hiroaki-Shinoda/Geniee-Android-SDK GitHub Wiki
VIDEO ads are displayed displayed at natural transition points in the flow of an app like interstitial ads, such as start-up the application, or between activities or during the pause between levels in a game.
Implementation preparation of video ads following Start guide,
it is necessary to install a Geniee SDK to the project.
Start Guide
Android video ad delivery use this following class.
- GNAdVideo Asynchronous retrieve the video ads, the class for display
- GNAdVideoListener Interstitial cycle event processing protocol
-
Import
GNAdVideo
import jp.co.geniee.gnadsdk.video.GNAdVideo; import jp.co.geniee.gnadsdk.video.GNAdVideo.GNAdVideoListener; import jp.co.geniee.gnadsdk.common.GNAdLogger;
-
Implement
GNAdVideoListener
interfacepublic class GNAdSampleVideo extends Activity implements GNAdVideoListener { }
-
Declare
GNAdVideo
of the variableGNAdVideo videoAd = null;
-
Initialize the instance of
GNAdVideo
-
API Initialized
public GNAdVideo(Context context, int appid)
-
Example for using API Initialized
videoAd = new GNAdVideo(this, YOUR_SSP_APP_ID_FOR_VIDEO);
- thisParameter sets Context of App.
- YOUR_SSP_APP_ID_FOR_VIDEO sets management ID of AdsZone in Geniee.
- Set the implementation class of
GNAdVideoListener
interface
Ad load and click events, you will be notified via the implementation class of interface.
Set the implementation class of GNAdVideoListener
interface
java videoAd.setListener(this);
- Example for GNAdSampleVideo implementation:
import jp.co.geniee.gnadsdk.video.GNAdVideo; import jp.co.geniee.gnadsdk.video.GNAdVideo.GNAdVideoListener; import jp.co.geniee.gnadsdk.common.GNAdLogger; public class GNAdSampleVideo extends ActionBarActivity implements GNAdVideoListener { private GNAdVideo videoAd = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gnad_sample_video); // Initializes a GNAdVideo videoAd = new GNAdVideo(this, YOUR_SSP_APP_ID_FOR_VIDEO); // The alternative interstitial ad will be shown when no video ad. //videoAd.setAlternativeInterstitialAppID(YOUR_SSP_APP_ID_FOR_INTERSTITIAL); videoAd.setListener(this); //videoAd.setAutoCloseMode(false); // Optional mode to automatically close after playing a video ad. Default: true //videoAd.setShowRate(100); // (Optional) Ad display frequency. (percentage):Set the number between 0-100 (%). Default: 100 //videoAd.setShowLimit(0); // (Optional) The maximum ad display numbers per app use. : Set the number 0 or higher. Default: 0 (No limited) //videoAd.setShowReset(0); // (Optional) The maximum reset fraction number of ad display per app //videoAd.setLogPriority(GNAdLogger.INFO); // (Optional) log level //videoAd.setGeoLocationEnable(true); // (Optional) location optimization. Default: false }
Load video ads display for the tag from Ad server.
GNAdVideo is preloaded before display, it is recommended that you use at the appropriate time to prepare for the ad has been completed.
- If it success to load, it will be notified by GNAdVideoListener
onGNAdVideoReceiveSetting
callback function of delegate. - If it fail to load, it will be notified by GNAdVideoListener
onGNAdVideoFailedToReceiveSetting
callback function of delegate.-
Load API
public void load(Activity activity)
-
Example for using load API
videoAd.load(this);
- Parameter
this
:Current screen of Activity variable
- Parameter
-
Please check the Video Ads is ready before delivery
- In the following example, to display video ads at the time of the screen transition.
-
Display API
public boolean isReady() public boolean show(Activity activity)
-
Example for using display
if (videoAd.isReady()) { videoAd.show(this); }
- Parameter
this
:Current screen of Activity variable
- Parameter
-
Update video ads, you will need to display to re-load ads.
-
When there is no stock or acquisition failure of video ads, you can display alternative interstitial ads.
-
Setting of alternative interstitial ads and set management ID of interstitial AdZone.
videoAd.setAlternativeInterstitialAppID(YOUR_SSP_APP_ID_FOR_INTERSTITIAL);
-
Implement CallBack function of
GNAdVideoListener
, you will receive advertisement processing cycle events.public static abstract interface GNAdVideoListener { // It will be sent when the reading of advertising data has been completed. public abstract void onGNAdVideoReceiveSetting(); // It will be sent to when that failed to read Ad in the cause such as a network error. public abstract void onGNAdVideoFailedToReceiveSetting(); // Video ad screen will be sent immediately after that is closed. public abstract void onGNAdVideoClose(); /// From the management screen, buttons were installed in advertising screen will be tapped. /// Alternate interstitial advertising screen will be sent immediately after that is closed. /// Number of buttons have been tapped, you will be notified by `nButtonIndex` parameters. public abstract void onGNAdVideoButtonClick(int nButtonIndex); }