×
Namespaces

Variants
Actions
(Difference between revisions)

Integrating Vserv Ads in Nokia X

From Nokia Developer Wiki
Jump to: navigation, search
mfabiop (Talk | contribs)
m (Mfabiop moved page Integrate Vserv Ads in NOKIA X to Integrating Vserv Ads in Nokia X: Changing NOKIA X to Nokia X)
BuildNokia (Talk | contribs)
(BuildNokia -)
Line 1: Line 1:
 
[[Category:Nokia X]][[Category:Nokia X 1.0]]
 
[[Category:Nokia X]][[Category:Nokia X 1.0]]
{{Abstract|This article explains step by step integration of Vserv Ads into Nokia X application using Vserv Android SDK }}  
+
{{Abstract|This article explains how to integrate Vserv Ads into Nokia X application using the Vserv Android SDK. }}  
 
  {{Note|This is an entry in the [[Nokia X Wiki Challenge 2014Q1]]}}
 
  {{Note|This is an entry in the [[Nokia X Wiki Challenge 2014Q1]]}}
 
{{ArticleMetaData <!-- v1.3 -->
 
{{ArticleMetaData <!-- v1.3 -->
Line 25: Line 25:
  
 
== Introduction ==
 
== Introduction ==
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.
+
The [http://www.vserv.mobi/ Vserv Ad Network] provides Advertisement support to almost all mobile platforms, including Nokia X - the newest addition to the Nokia family. I will use the Vserv Android SDK for integration. This can be performed by following the steps described below.
 
+
 
+
  
 
==Implementation==
 
==Implementation==
Line 33: Line 31:
  
 
===Register as Developer===
 
===Register as Developer===
First thing needed is a Developer Account.If you don't have one, register on the  'http://www.vserv.mobi' as Developer, your Default Zone ID will be sent to you in your welcome Email. I will use Default Zone ID
+
First, you'll need a Developer Account. If you don't have one, [http://www.vserv.mobi/get-started/?at=developer register as a developer on the Vserv site]. Your Default Zone ID will be sent to you in your welcome email. I will use my Default Zone ID in the sample, but you can create as many Zone IDs as you want on the Vserv Dashboard, each with a different category.  If you already have a Vserv developer account and Default Zone ID you can skip this step.
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===
 
=== Download Vserv Android SDK===
you can download Vserv Android SDK [http://www.vserv.mobi/sdk/app_invocation/Billboard/Android/SDK/VservAndroidSDK.zip here]. Unzip the downloaded file. there would be a folder named as AndroidV2SDKLibrary/ which contain Vserv Android SDK.
+
Next, [http://www.vserv.mobi/sdk/app_invocation/Billboard/Android/SDK/VservAndroidSDK.zip download download the Vserv Android SDK]. Unzip the downloaded file, and you'll have a folder named as {{Icode|AndroidV2SDKLibrary/}} which contains the Vserv Android SDK.
 
+
  
 
===Integrate Vserv Android SDK Library===
 
===Integrate Vserv Android SDK Library===
Now import Vserv Android SDK library in the Project. Next step will be to add library into the Project. Go to Project->Property->Android and select the bibrary and ad it into the Project.   
+
Now import the Vserv Android SDK library into your Project as follows:
 
+
* Navigate to ''Project->Property->Android''
 +
* Select the Vserve Android SDK library and add it into the Project.   
  
 
===Updating your project.properties===
 
===Updating your project.properties===
Now Update update project.properties file and add below code in the File
+
Now add the following code to your {{Icode|project.properties}} file.
  
 
<code>                     
 
<code>                     
Line 53: Line 49:
  
 
===Update Vserv Library AndroidManifest ===
 
===Update Vserv Library AndroidManifest ===
Now update the AndroidManifest.xml File in the Vserv Library. Delete the following code from the File
+
Now update the {{Icode|AndroidManifest.xml}} File in the Vserv Library. Delete the following code from the file.
  
 
<code xml>
 
<code xml>
Line 61: Line 57:
  
 
===Provide Internet Access Permission===
 
===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.
+
Your App will need internet access to fetch ads from the Vserv Ad Network. Therefore, you have to provide internet access permissions by adding the following code to the {{Icode|AndroidManifest.xml}} File. Add it outside the application tag.
  
 
<code xml>
 
<code xml>
Line 68: Line 64:
  
 
===Request Vserv Ads===
 
===Request Vserv Ads===
Only thing now left to request Ads from Vserv Ad Network.The Vserv.mobi SDK provides you with various mechanisms to request for Ads in your Android application.  
+
FInally you need to request ads from the Vserv Ad Network. The Vserv.mobi SDK provides you with various mechanisms to request ads from your Nokia X application.  
 
+
  
 
====Requesting Ads using displayAd()====
 
====Requesting Ads using displayAd()====
{{Icode|displayAd()}} method have three constructor to request Ads.
+
{{Icode|displayAd()}} has three constructors that can be used to request Ads.
 
+
  
 
=====Managed  Ads using displayAd()=====
 
=====Managed  Ads using displayAd()=====
First create object of VservManager(mobi.vserv.android.ads) and initialize it. Now request ads using displayAd() of VservManager Object.
+
First, create and initialize an instance {{Icode|VservManager(mobi.vserv.android.ads)}}. Now request ads using the {{Icode|displayAd()}} of the {{Icode|VservManager}} object.
  
 
<code java>
 
<code java>
Line 84: Line 78:
 
</code>
 
</code>
  
YOUR_ZONE_ID is Zone ID you received in the Welcome Email.  
+
{{Icode|YOUR_ZONE_ID}} is the Zone ID you received in the Welcome Email from Vserv.
  
  
 
=====Overlay Ads using displayAd()=====
 
=====Overlay Ads using displayAd()=====
The {{Icode|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 {{Icode|displayAd()}} method.
+
By default, the {{Icode|DisplayAd()}} method displays an interstitial. However itcan be used to display an Overlay ad for a more native experience. To request an Overlay ad you need to pass {{Icode|AdType.OVERLAY}} to the Overloaded {{Icode|displayAd()}} method.
  
 
<code java>
 
<code java>
Line 100: Line 94:
 
=====Orientation Ads in displayAd()=====
 
=====Orientation Ads in displayAd()=====
  
You can request for an interstitial in a particular orientation by passing an AdOrientation parameter to {{Icode|displayAd()}} as shown.
+
You can request for an interstitial in a particular orientation by passing an {{Icode|AdOrientation}} parameter to {{Icode|displayAd()}} as shown.
  
 
<code java>
 
<code java>
Line 109: Line 103:
  
 
Ad orientation will either be {{Icode|AdOrientation.LANDSCAPE}} or {{Icode|AdOrientation.PORTRAIT}}
 
Ad orientation will either be {{Icode|AdOrientation.LANDSCAPE}} or {{Icode|AdOrientation.PORTRAIT}}
 
  
 
====Requesting Ads using getAd()====
 
====Requesting Ads using getAd()====
  
This mechanism gives you the maximum control over Ad retrieval. {{Icode|getAd()}} allows you to prefetch multiple Ads. It takes in two parameters, a ZoneID and an AdLoadCallBack listener.
+
This mechanism gives you the maximum control over Ad retrieval. {{Icode|getAd()}} allows you to prefetch multiple ads. It takes in two parameters, a {{Icode|ZoneID}} and an {{Icode|AdLoadCallBack}} listener.
  
 
<code java>
 
<code java>
Line 119: Line 112:
 
</code>
 
</code>
  
In addition you can also request for a particular orientation by passing an AdOrientation parameter.
+
You can also request a particular ad orientation with {{Icode|getAd()}} by passing an {{Icode|AdOrientation}} parameter.
  
 
<code java>
 
<code java>
Line 125: Line 118:
 
</code>
 
</code>
  
The {{Icode|AdLoadCallback}} (mobi.vserv.android.appwrapper.AdLoadCallback) interface provides callsbacks to get the status of you’re a Request. It has the following callbacks:
+
The {{Icode|AdLoadCallback}} (mobi.vserv.android.appwrapper.AdLoadCallback) interface provides callbacks to get the status of your request. It has the following callbacks:
  
 
<code java>
 
<code java>
 
     onLoadSuccess(VservAd adObj)
 
     onLoadSuccess(VservAd adObj)
 
</code>
 
</code>
This callback method is invoked when an Ad has been successfully retrieved.  
+
 
 +
This callback method is invoked when an ad has been successfully retrieved.  
  
 
<code java>
 
<code java>
 
     onLoadFailure()
 
     onLoadFailure()
 
</code>
 
</code>
This callback method is invoked when there is an error in retrieving the Ad from the Vserv Ad Network.
+
 
 +
This callback method is invoked when there is an error in retrieving the ad from the Vserv Ad Network.
  
 
<code java>
 
<code java>
 
     onNoFill()
 
     onNoFill()
 
</code>
 
</code>
This callback method is invoked when there is no Ad available.
 
  
A sample implementation of the getAd() method with the callback is shown below. This sample used the {{Icode|overlay()}} method to show the interstitial immediately.
+
This callback method is invoked when there is no ad available.
 +
 
 +
A sample implementation of the {{Icode|getAd()}} method with the callback is shown below. This sample used the {{Icode|overlay()}} method to show the interstitial immediately.
  
 
<code java>
 
<code java>
Line 166: Line 162:
  
 
====Managed Banner Ads using renderAd()====
 
====Managed Banner Ads using renderAd()====
You can request for Banner Ads which auto refresh automatically in a specific View using {{Icode|renderAd()}}. The signature for the method is shown below:
+
You can request banner ads that automatically auto refresh in a specific view using {{Icode|renderAd()}}. The method signature is shown below:
  
 
<code java>
 
<code java>
Line 172: Line 168:
 
</code>
 
</code>
  
The ViewGroup is a container in your Activity layout where you want the Ad to be displayed.
+
The {{Icode|ViewGroup}} is a container in your activity layout where you want the ad to be displayed.
  
 
== Summary ==
 
== Summary ==
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 {{Icode|displayAd()}} method and on the click on Button using the {{Icode|getAd()}} method.
+
By following the above-mentioned steps, you can easily integrate Vserv Ads into Nokia X apps.  
  
Feel free to edit this Article.
+
The source code of an app that implements Vserv Ads is attached. This app shows Vserv Ads upon app launch and close using the {{Icode|displayAd()}} method, and when a button click event fires using the {{Icode|getAd()}} method.

Revision as of 21:50, 17 April 2014

This article explains how to integrate Vserv Ads into Nokia X application using the Vserv Android SDK.

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

Article Metadata
Code Example
Source file: Media:Vservads.zip
Tested with
Devices(s): NOKIA X Emulator
Platform Security
Capabilities: ACCESS_NETWORK_STATE
Article
Created: pardeepsharma10 (13 Apr 2014)
Last edited: BuildNokia (17 Apr 2014)


Contents

Introduction

The Vserv Ad Network provides Advertisement support to almost all mobile platforms, including Nokia X - the newest addition to the Nokia family. I will use the Vserv Android SDK for integration. This can be performed by following the steps described below.

Implementation

Register as Developer

First, you'll need a Developer Account. If you don't have one, register as a developer on the Vserv site. Your Default Zone ID will be sent to you in your welcome email. I will use my Default Zone ID in the sample, but you can create as many Zone IDs as you want on the Vserv Dashboard, each with a different category. If you already have a Vserv developer account and Default Zone ID you can skip this step.

Download Vserv Android SDK

Next, download download the Vserv Android SDK. Unzip the downloaded file, and you'll have a folder named as AndroidV2SDKLibrary/ which contains the Vserv Android SDK.

Integrate Vserv Android SDK Library

Now import the Vserv Android SDK library into your Project as follows:

  • Navigate to Project->Property->Android
  • Select the Vserve Android SDK library and add it into the Project.

Updating your project.properties

Now add the following code to your project.properties file.

manifestmerger.enabled=true

Update Vserv Library AndroidManifest

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

<metadata
android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

Provide Internet Access Permission

Your App will need internet access to fetch ads from the Vserv Ad Network. Therefore, you have to provide internet access permissions by adding the following code to the AndroidManifest.xml File. Add it outside the application tag.

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

Request Vserv Ads

FInally you need to request ads from the Vserv Ad Network. The Vserv.mobi SDK provides you with various mechanisms to request ads from your Nokia X application.

Requesting Ads using displayAd()

displayAd() has three constructors that can be used to request Ads.

Managed Ads using displayAd()

First, create and initialize an instance VservManager(mobi.vserv.android.ads). Now request ads using the displayAd() of the VservManager object.

    VservManager manager = VservManager.getInstance(context);
manager.setShowAt(AdPosition.IN);
manager.displayAd(ZONE_ID);

YOUR_ZONE_ID is the Zone ID you received in the Welcome Email from Vserv.


Overlay Ads using displayAd()

By default, the DisplayAd() method displays an interstitial. However itcan be used to display an Overlay ad for a more native experience. To request an Overlay ad you need to pass AdType.OVERLAY to the Overloaded displayAd() method.

    VservManager manager = VservManager.getInstance(context);
manager.setShowAt(AdPosition.IN);
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.setShowAt(AdPosition.IN);
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)

You can also request a particular ad orientation with getAd() by passing an AdOrientation parameter.

    getAd(ZONE_ID, AdOrientation adOrientation, AdLoadCallback myAdLoadCallbackListener)

The AdLoadCallback (mobi.vserv.android.appwrapper.AdLoadCallback) interface provides callbacks to get the status of your request. It has the following callbacks:

    onLoadSuccess(VservAd adObj)

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

    onLoadFailure()

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

    onNoFill()

This callback method is invoked when there is 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) {
adObj.overlay(context);
}
 
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 banner ads that automatically auto refresh in a specific view using renderAd(). The method signature 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.

Summary

By following the above-mentioned steps, you can easily integrate Vserv Ads into Nokia X apps.

The source code of an app that implements Vserv Ads is attached. This app shows Vserv Ads upon app launch and close using the displayAd() method, and when a button click event fires using the getAd() method.

466 page views in the last 30 days.
×