Use Keymob in Javaadmin To Published in 2015-06-26 android( Read:3471

Use Keymob in Java 

 a.add import

import com.keymob.ads.AdManager;
import com.keymob.core.*;

Before using keymob, first import keymob related class files. Most of the core classes in com.keymob.core package, so you can import all at once. AdManager as the main class of keymob , also need to be imported.
  
 b.Setup and initialize keymob

AdManager.getInstance().initFromJSON(active,jsonString,new  AdEventListener());

   The first parameter  is context active, it as necessary, and can not be null.
  The second parameter is the config info of each platform in json string format,json format reference template.
  The third parameter is   event listener of advertising,witch is a class that implements interface IAdEventListener, if you do not want to deal with advertising events, you can set it to null.

 c. Display banner advertising

AdManager.getInstance().showRelationBanner(BannerSizeType.BANNER, BannerPositions.BOTTOM_CENTER,80);

The above means that displays the standard banner ad at the bottom of the device . The first parameter is the ad size, the type size can be selected in BannerSizeType constants, including the standard banner, rectange banner, smart banner and so on.
  Other banner size outside  standard size(320*50) may have  small differences in the different platforms, run to see the effects.
  The second parameter is the position of the banner displayed,  the value of each position is  in BannerPositions constants,including the top left, top center, top right-hand and so on ,9 kinds of common position total.
  The third parameter is offsetY, i.e., the relative positional deviation, e.g., on the bottom of the application, the upward offset 80 pixels, that is, the effect of the above code. If you want to stick to the bottom of the application, set the offsetY 0.
 
 d. display banner at Fixed location

AdManager.getInstance().showBannerABS(BannerSizeType.BANNER, 0, 200);

The above code is display standard banner at point(0,200)
     Although the relative positioning to meet the needs of the majority of advertising location settings, but to meet the needs of some special position, keymob provides absolute fixed position display banner advertising api.
     The first parameter is the size of the banner, the second argument and third parameters are the position x and y values of banner.

 e. Hide banne ad

AdManager.getInstance().removeBanner();

   "removeBanner" hidden banner advertising, but advertising will not be destroyed so show can be quickly presented to the user next time. Some advertising platform will continue to  load ad after hidden , so the event will dispatched also.

f. Load and display Interstitial ads     

AdManager.getInstance().loadInterstitial();

   Load Interstitial ads, does not automatically show after load successfully, this can better control Interstitial ad at the right time to show to the user,
    If you want to show immediate after load,just handler onLoadedSuccess  in eventListener and call showInterstitial.

AdManager.getInstance().showInterstitial();

   Display Interstitial advertising, ads will appear immediately after the call showInterstitial. However, please ensure that advertising has finished loading.

AdManager.getInstance().isInterstitialReady();

   Check the Interstitial ad is loaded complete. If call showInterstitial directly when an ad  has not finished loading unpredictable events will occur, som advertising platform could lead to crash.
    So make sure the Interstitial is ready before every show.Below is the overall look.

if(AdManager.getInstance().isInterstitialReady()){
AdManager.getInstance().showInterstitial();
}

g. Load and display video ads

AdManager.getInstance().loadVideo();



  Load video ads, does not automatically show after load successfully, this can better control video ad at the right time to show to the user,

    If you want to show immediate after load,just handler onLoadedSuccess  in eventListener and call showVideo.

AdManager.getInstance().showVideo();

   Display video ads, ads will appear immediately after the call showVideo. However, please ensure that advertising has finished loading.

AdManager.getInstance().isVideoReady();

  Check the video ad is loaded complete. If call showVideo directly when an ad  has not finished loading unpredictable events will occur, some advertising platform could lead to crash.

    So make sure the video is ready before every show.Below is the overall look.

   	if(AdManager.getInstance().isVideoReady()){
         AdManager.getInstance().showVideo();
        }

 h. Application load and display more app advertising

AdManager.getInstance().loadAppWall();

   Load more app ads, does not automatically show after load successfully, this can better control video ad at the right time to show to the user,

    If you want to show immediate after load,just handler onLoadedSuccess  in eventListener and call showAppWall.

AdManager.getInstance().showAppWall();

   Display more app ads, ads will appear immediately after the call showAppWall. However, please ensure that advertising has finished loading.
   Check the More App ad is loaded complete. If call showAppWall directly when an ad  has not finished loading unpredictable events will occur, some advertising platform could lead to crash.
    So make sure the More App is ready before every show.Below is the overall look.

if(AdManager.getInstance().isAppWallReady()){
AdManager.getInstance().showAppWall();
}

next:Tutorial 1

0 Reviews,0 Participation.

Previous Next 0

Latest comments

No comment Oh!