Namespaces

Variants
Actions

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
pardeepsharma10 (Talk | contribs)
(Pardeepsharma10 -)
pardeepsharma10 (Talk | contribs)
(Pardeepsharma10 -)
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 App using Vserv Android SDK }}  
+
{{Abstract|This article explains step by step integration of Vserv Ads into Nokia X application using 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.
+
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.
  
  
Line 33: Line 33:
  
 
===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 would be sent to you in your welcome Email. I will use Default Zone ID
+
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
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.
+
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===
Next step would be to Download Vserv Android SDK, you can download it here[[http://www.vserv.mobi/sdk/app_invocation/Billboard/Android/SDK/VservAndroidSDK.zip]]. Unzip the Downloaded File. there would be a Folder named as AndroidV2SDKLibrary/ which contain 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.
  
  
 
===Integrate Vserv Android SDK Library===
 
===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.   
+
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.   
  
  
 
===Updating your project.properties===
 
===Updating your project.properties===
Next step would be to update project.properties file. add below code in the File
+
Now Update update project.properties file and add below code in the File
  
 
<code>                     
 
<code>                     
Line 135: Line 135:
 
     onLoadFailure()
 
     onLoadFailure()
 
</code>
 
</code>
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 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 was no Ad available.
+
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.
 
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.

Revision as of 06:13, 17 April 2014

This article explains step by step integration of Vserv Ads into Nokia X application using 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: pardeepsharma10 (17 Apr 2014)


Contents

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.


Implementation

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 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

you can download Vserv Android SDK here. 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 will be to add library into the Project. Go to Project->Property->Android and select the bibrary and ad it into the Project.


Updating your project.properties

Now Update update project.properties file and add below code in the 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 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 Vserv.mobi 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(mobi.vserv.android.ads) and initialize it. Now request ads using displayAd() of VservManager Object.

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

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.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)

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

    getAd(ZONE_ID, AdOrientation adOrientation, AdLoadCallback myAdLoadCallbackListener)

The AdLoadCallback (mobi.vserv.android.appwrapper.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.

    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 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.

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 displayAd() method and on the click on Button using the getAd() method.

Feel free to edit this Article.

383 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.

×