在Android上预加载RevMob广告

时间:2012-12-05 08:51:31

标签: android revmob

我正在寻找在我的Android应用中预加载RevMob Banner和非页内广告的方法吗?广告目前可能需要5到30秒的时间,这对于应用类型而言是很长的。

感谢任何帮助。

3 个答案:

答案 0 :(得分:1)

如果您使用广告对象,则可以执行预加载(RevMob API Docs)并显示如下:

Fullscreen fullscreen = revmob.createFullscreen(this);
if (fullscreen.isAdLoaded()) {
  fullscreen.show();
}

但只有广告已加载时,该节目才有效!

答案 1 :(得分:0)

在最新版本中,有一些重要的变化。只有在实施某些中介策略时,才必须使用“isAdLoaded”。否则,您可以直接使用“show”和“hide”方法。

RevMob revmob = RevMob.start(this, APPLICATION_ID);    
RevMobFullscreen fullscreen = revmob.createFullscreen(this);
// it will show the ad. If it is not loaded yet, it will show it after it is completely loaded automatically.
fullscreen.show();
// If you change your scene and you do not want to show the ad anymore, you can call this method:
fullscreen.hide();

http://sdk.revmob.com/android-api/index.html

答案 2 :(得分:0)

添加到AndrodMainfest.xml文件

      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
       <uses-permission android:name="android.permission.READ_PHONE_STATE" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
          <activity
        android:name="com.revmob.ads.fullscreen.FullscreenActivity"
        android:configChanges="keyboardHidden|orientation" >
    </activity>

//私人RevMobFullscreen全屏;

   private static final String REVMOB_APP_ID = "rebmob_id";
 private RevMob revmob;
 RevMobAdsListener revmobListener;
                @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    onStart();
    // Starting RevMob session
    revmob = RevMob.start(this, REVMOB_APP_ID);
    revmob.printEnvironmentInformation(this);

    revmob.setTestingMode(RevMobTestingMode.WITH_ADS); // with this line,
                                                        // RevMob will
                                                        // always deliver a
                                                        // sample ad
    // revmob.setTestingMode(RevMobTestingMode.WITHOUT_ADS);
    // revmob.createFullscreen(this, revmobListener);
    //
    revmob.showFullscreen(this);
    revmob.setTimeoutInSeconds(5);
           }

方法呼叫

   public void onStart() {
       super.onStart();
         revmobListener = new RevMobAdsListener() {
        @Override
        public void onRevMobAdDisplayed() {
            Log.i("[RevMob]", "onAdDisplayed");
        }

        @Override
        public void onRevMobAdReceived() {
            Log.i("[RevMob]", "onAdReceived");
        }

        @Override
        public void onRevMobAdNotReceived(String message) {
            Log.i("[RevMob]", "onAdNotReceived");
        }

        @Override
        public void onRevMobAdDismiss() {
            Log.i("[RevMob]", "onAdDismiss");
        }

        @Override
        public void onRevMobAdClicked() {
            Log.i("[RevMob]", "onAdClicked");
        }
    };
   }

   public void showFullscreen(View view) {
        RevMobFullscreen fs = revmob.createFullscreen(this, revmobListener);
    fs.show();
   }

    public void revMobOpenPopup(View view) {
    // revmob.showPopup(this);
    RevMobPopup popup = revmob.createPopup(this, revmobListener);
    popup.show();
}