Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

(Difference between revisions)

Integrating Vserv Ads in Nokia X

From Wiki
Jump to: navigation, search
mfabiop (Talk | contribs)
(Mfabiop -)
pardeepsharma10 (Talk | contribs)
(Pardeepsharma10 -)
Line 18: Line 18:
|update-by= <!-- After significant update: [[User:username]]-->
|update-by= <!-- After significant update: [[User:username]]-->
|update-timestamp= <!-- After significant update: YYYYMMDD -->
|update-timestamp= <!-- After significant update: YYYYMMDD -->
|creationdate= <!-- Format YYYYMMDD -->
|creationdate=20140413 <!-- Format YYYYMMDD -->
|author= [[User:pardeepsharma10]]<!-- Enter link [[User:username]] -->
|author= [[User:pardeepsharma10]]<!-- Enter link [[User:username]] -->

Revision as of 18:44, 15 April 2014

This article explains step by step integration of Vserv Ads into NOKIA X App using Vserv Android SDK

Note.pngNote: This is an entry in the Nokia X Wiki Challenge 2014Q1

Article Metadata
Code Example
Source file:
Tested with
Devices(s): NOKIA X Emulator
Platform Security
Created: pardeepsharma10 (13 Apr 2014)
Last edited: pardeepsharma10 (15 Apr 2014)



Vserv Ad Network provide Advertisement support to almost all the Mobile Platform including 'NOKIA X'-the newest addition to the NOKIA family.I will use Vserv Android SDK for integration. this can be performed in number of steps described below.


Register as Developer

First thing needed is a Developer Account.If you don't have one, register on the '' as Developer, your Default Zone ID would be sent to you in your welcome Email. I will use Default Zone ID in the sample, but you can create as many Zone ID as you want on Vserv Dashboard having different Categories. If you already have Developer account and Default Zone ID skip this Step.

Download Vserv Android SDK

Next step would be to Download Vserv Android SDK, you can download it here[[1]]. Unzip the Downloaded File. there would be a Folder named as AndroidV2SDKLibrary/ which contain Vserv Android SDK.

Integrate Vserv Android SDK Library

Now import Vserv Android SDK library in the Project. Next step would be add library into the Project. Go to Project->Property->Android and select the Library and ad it into the Project.

Updating your

Next step would be to update file. add below code in the File


Update Vserv Library AndroidManifest

Now update the AndroidManifest.xml File in the Vserv Library. Delete the following code from the File

android:name="" android:value="@integer/google_play_services_version" />

Provide Internet Access Permission

Your App will need internet to fetch Ads from Vserv Ad Network. So, you have to provide Internet access permission which can be done by following code in the AndroidManifest.xml File. add it outside application tag.

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Request Vserv Ads

Only thing now left to request Ads from Vserv Ad Network.The SDK provides you with various mechanisms to request for Ads in your Android application.

Requesting Ads using displayAd()

displayAd() method have three constructor to request Ads.

Managed Ads using displayAd()

First create object of VservManager( and initialize it. Now request ads using displayAd() of VservManager Object.

    VservManager manager = VservManager.getInstance(context);

YOUR_ZONE_ID is Zone ID you received in the Welcome Email.

Overlay Ads using displayAd()

The DisplayAd() method by default displays an interstitial but can be used to display an Overlay ad for a more native experience. To request an Overlay ad you need to pass the AdType to the Overloaded displayAd() method.

    VservManager manager = VservManager.getInstance(context);
manager.displayAd(ZONE_ID, AdType.OVERLAY);

You can pass either AdType.OVERLAY & AdType.INTERSTITIAL to displayAd().

Orientation Ads in displayAd()

You can request for an interstitial in a particular orientation by passing an AdOrientation parameter to displayAd() as shown.

    VservManager manager = VservManager.getInstance(context);
manager.displayAd(ZONE_ID, AdOrientation.LANDSCAPE);

Ad orientation will either be AdOrientation.LANDSCAPE or AdOrientation.PORTRAIT

Requesting Ads using getAd()

This mechanism gives you the maximum control over Ad retrieval. getAd() allows you to prefetch multiple Ads. It takes in two parameters, a ZoneID and an AdLoadCallBack listener.

    getAd(ZONE_ID, AdLoadCallback myAdLoadCallbackListener)

In addition you can also request for a particular orientation by passing an AdOrientation parameter.

    getAd(ZONE_ID, AdOrientation adOrientation, AdLoadCallback myAdLoadCallbackListener)

The AdLoadCallback ( interface provides callsbacks to get the status of you’re a Request. It has the following callbacks:

    onLoadSuccess(VservAd adObj)

This callback method is invoked when an Ad has been successfully retrieved.


This callback method is invoked when there was an error in retrieving the Ad from the Vserv Ad Network.


This callback method is invoked when there was no Ad available.

A sample implementation of the getAd() method with the callback is shown below. This sample used the overlay() method to show the interstitial immediately.

    final Context context=MainActivity.this;
VservManager manager = VservManager.getInstance(context);
manager.getAd("ZONE_ID", new AdLoadCallback() {
public void onLoadSuccess(VservAd adObj) {
public void onLoadFailure() {
// code to execute on Failure of Ads loading
public void onNoFill() {
// Code when no ads are returned

Managed Banner Ads using renderAd()

You can request for Banner Ads which auto refresh automatically in a specific View using renderAd(). The signature for the method is shown below:

    VservController renderAd(String zoneId, ViewGroup viewGroup)

The ViewGroup is a container in your Activity layout where you want the Ad to be displayed.


Following above mentioned steps would help you easily integrate Vserv Ads into NOKIA X Apps. Developers can also earn some Reward points in DVLUP- NOKIA Reward Program by participating in Challenges. Source Code of App implementing Vserv Ads is Attached. App shows Vserv Ads on App Lunching, Closing using displayAd() method and on the click on Button using the getAd() method.

Feel free to edit this Article.

292 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.