Configuration
Access the RevMob Console and register your application to get your RevMob App ID;
Download the latest version of the SDK;
Add the required permissions in your AndroidManifest.xml file by putting the following code inside the
tag.
<!-- Required -->
<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"/>
- The others are optional, but we highly recommend to increase the eCPM.
<!-- Strongly recommended -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Create a libs/ folder on your Eclipse project, and copy the library JAR ( revmob-n.n.n.jar , where n.n.n is the version) there. Make sure the lib is ticked in the Order and Export tab of the Java Build Path panel.
Add the library to your project's build path, by right-clicking the file on Eclipse, selecting Build Path, then Add to Build Path.
Start Session
Before showing any ads, you must start a RevMob session with your RevMob App ID.
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import com.revmob.RevMob;
public class YourMainActivity extends Activity {
private static final String REVMOB_APP_ID = "copy your RevMob App ID here";
private RevMob revmob;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Starting RevMob session
revmob = RevMob.start(this, REVMOB_APP_ID);
}
}
In another activities you can use
revmob = RevMob.session(this)instead of thestartmethod.You can put the code in the
onResumemethod of your activity too. Check the Activity Lifecycle.
Testing Mode
While you are developing your app, you will probably want to test two scenarios:
- When the RevMob show an advertisement successfully.
- When the RevMob does not deliver an advertisement because some internal rule.
Activating the testing mode you are allowed to reproduce these two scenarios easily. And you do not need to worry about statistics because the prints/clicks/installs are not counted.
Just be sure to disable/delete the testing mode before publishing your app to the store.
revmob = RevMob.start(this, REVMOB_APP_ID);
revmob.setTestingMode(RevMobTestingMode.WITH_ADS); // with this line, RevMob will always deliver a sample ad
revmob.setTestingMode(RevMobTestingMode.WITHOUT_ADS); // with this line, RevMob will not delivery ads
Fullscreen

Fullscreen is a ad unit with a high eCPM. You can show it in the beginning or in the end of a round, for example.
To show a Fullscreen Ad you need to:
- Add access control on your AndroidManifest.xml. Just add the RevMob activity in the application node:
<application>
<activity android:name="com.revmob.ads.fullscreen.FullscreenActivity"
android:configChanges="keyboardHidden|orientation">
</activity>
</application>
- Then, just call the
showFullscreenmethod:
public class YourActivity extends Activity {
public void onResume(Bundle savedInstanceState) {
super.onResume(savedInstanceState);
setContentView(R.layout.activity_main);
RevMob revmob = RevMob.start(this, REVMOB_APP_ID);
revmob.showFullscreen(this);
}
}
- Or you can pre-load the ad:
import com.revmob.ads.fullscreen.RevMobFullscreen;
public class YourActivity extends Activity {
private RevMobFullscreen fullscreen;
public void onResume(Bundle savedInstanceState) {
super.onResume(savedInstanceState);
setContentView(R.layout.activity_main);
RevMob revmob = RevMob.start(this, REVMOB_APP_ID);
fullscreen = revmob.createFullscreen(this); // pre-load it without showing it
}
public void gameOverScreen() {
fullscreen.show(); // call it wherever you want to show the fullscreen ad
}
}
Banner

The banner ad is an Android View. You can add it programatically or using the Android layout files.
Here is an example using a LinerLayout, declared in a layout xml file (main.xml):
<LinearLayout android:id="@+id/banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</LinearLayout>
And in the activity, put the banner as a child of a LinearLayout:
import com.revmob.ads.banner.RevMobBanner;
public class YourActivity extends Activity {
public void onResume(Bundle savedInstanceState) {
super.onResume(savedInstanceState);
setContentView(R.layout.main);
RevMob revmob = RevMob.start(this, REVMOB_APP_ID);
RevMobBanner banner = revmob.createBanner(this);
ViewGroup view = (ViewGroup) findViewById(R.id.banner);
view.addView(banner);
}
}
By default the banner fits all available widths, adjusting the height to keep the aspect ratio constant. You can also provide a custom width and/or height. If you provide a layout_width param, the banner will try to fit the entire width and adjust the height; If you provide a layout_height param, the banner will try to fit the entire height and adjust the width; If you provide both, a layout_width and a layout_height, the banner will try to fit the whole area. If you set layout_width and/or layout_height, include the atrribute android:visibility="gone" to the layout, example:
<LinearLayout android:id="@+id/banner"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:visibility="gone">
</LinearLayout>
Link
Use the Link to redirect the user to the advertised mobile application download page. A common usage is to associate the link to a "more games" button or to a custom banner. Be sure you are using listeners to check if the link was loaded successfully, otherwise you create a workaround for this situation, like hide the button.
import com.revmob.ads.banner.RevMobLink;
public class YourActivity extends Activity {
public void onResume(Bundle savedInstanceState) {
super.onResume(savedInstanceState);
setContentView(R.layout.main);
RevMob revmob = RevMob.start(this, REVMOB_APP_ID);
RevMobAdsListener listener = new RevMobAdsListener() {
public void onRevMobAdReceived() { Log.i("[RevMob]", "onAdReceived"); }
public void onRevMobAdNotReceived(String message) {} // you can create an workaround here
public void onRevMobAdDisplayed() {}
public void onRevMobAdDismiss() {}
public void onRevMobAdClicked() {}
};
RevMobLink link = revmob.openAdLink(this, listener);
}
}
A good idea is to pre-load the link.
import com.revmob.ads.banner.RevMobLink;
public class YourActivity extends Activity {
private RevMobLink link;
public void onResume(Bundle savedInstanceState) {
super.onResume(savedInstanceState);
setContentView(R.layout.main);
RevMob revmob = RevMob.start(this, REVMOB_APP_ID);
RevMobAdsListener listener = new RevMobAdsListener() {
public void onRevMobAdReceived() { Log.i("[RevMob]", "onAdReceived"); }
public void onRevMobAdNotReceived(String message) {} // you can hide the More Games Button here
public void onRevMobAdDisplayed() {}
public void onRevMobAdDismiss() {}
public void onRevMobAdClicked() {}
};
link = revmob.createAdLink(this, listener);
Button buttonMoreGames; // instantiate it
buttonMoreGames.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
link.open();
}
});
}
}
Notification

The notification ad will send a message to the user, even if your app is closed.
This ad unit schedule a local notification for your application. Pay attention because you have to implement this ad unit in two steps: 1) schedule it and; 2) handle it.
- ps: You can schedule when the message will appear to the user, or you can let the RevMob servers decide the best moment to show it.
To show a Notification ad you have to include two lines of code, one to schedule the notification and another one to open it. Both of them must be in the same activity. Also, you must set a drawable icon, because we want to mantain compatibility with older versions of Android SDK. Follow the example:
import android.app.Activity;
import com.revmob.RevMob;
public class MainActivity extends Activity {
private RevMob revmob;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
revmob = RevMob.start(this, REVMOB_APP_ID);
// It must be in the onCreate method of your Main activity
revmob.openNotification(this);
// call it wherever you want to
revmob.scheduleNotification(this, R.drawable.YOUR_ICON_IMAGE);
}
}
Popup

Popup is the simplest ad unit. We recommend it only for apps that will be intensively used by old devices with a slow internet connection. For all the other cases, we recommend you to use the fullscreen ad unit.
public class YourActivity extends Activity {
public void onResume(Bundle savedInstanceState) {
super.onResume(savedInstanceState);
setContentView(R.layout.activity_main);
RevMob revmob = RevMob.start(this, REVMOB_APP_ID);
revmob.showPopup(this);
}
}
- Or you can pre-load the ad:
import com.revmob.ads.popup.RevMobPopup
public class YourActivity extends Activity {
private RevMobPopup popup;
public void onResume(Bundle savedInstanceState) {
super.onResume(savedInstanceState);
setContentView(R.layout.activity_main);
RevMob revmob = RevMob.start(this, REVMOB_APP_ID);
popup = revmob.createPopup(this); // pre-load it without showing it
}
public void gameOverScreen() {
popup.show(); // call it wherever you want to show the popup ad
}
}
Listeners - Delegates
With Listeners (also known as Delegates or Callbacks) you can follow the ad workflow. The RevMob SDK will fire events for every important change in the ad state. For example, you can identify if the ad was loaded successfully or you can identify if the user clicked in the ad.
To use listeners, you must create a concrete class that implements the RevMobAdsListener interface. This class can be anonymous, like the following one:
RevMobAdsListener 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");
}
};
After, you must pass an instance of the listener to the RevMob methods:
// each ad unit instance can have its own and independent listener
revmob.createFullscreen(this, revmobListener);
revmob.createAdLink(this, revmobListener);
revmob.createBanner(this, revmobListener);
revmob.createPopup(this, revmobListener);
Placement IDs
Placement ID is an optional feature recommended for experient publishers. If you want to enable/disable specific ad units in real time, or, if you want to have an exclusive tracking for an ad unit, you must use Placement IDs (do not confuse with App ID). First of all, you need to create one or more Placement IDs (for each ad unit) in the RevMob Console. Then copy the corresponding ID, and pass it through the ad method calls.
These are some methods you can call to use Placement IDs:
// replace these Placement IDs for your own.
revmob.createFullscreen(this, "copy your fullscreen placement ID here", revmobListener);
revmob.createAdLink(this, "copy your link placement ID here", revmobListener);
revmob.createBanner(this, "copy your banner placement ID here", revmobListener);
revmob.createPopup(this, "copy your popup placement ID here", revmobListener);
revmob.scheduleNotification(this, R.drawable.YOUR_ICON_IMAGE, "copy your notification placement ID here", revmobListener)
Timeout
You can change the connection timeout to the RevMob servers, if necessary.
RevMob revmob = RevMob.start(this, REVMOB_APP_ID);
revmob.setTimeoutInSeconds(5);
Contact
If you are having any issue to integrate the RevMob SDK, send us a message clicking in the Contact Us link in the RevMob Web Site. To accelerate the response of our team, please, attach the console logs printed by the following command that print a summary of your environment configuration.
RevMob revmob = RevMob.start(this, REVMOB_APP_ID);
revmob.printEnvironmentInformation(this);








