Millennial Media (formerly Jumptap) Android SDK Integration

From Millennial Media
Jump to: navigation, search

Contents

Overview

This wiki page describes the Millennial Media Android (JtAdView) ad library installation and use for Android developers.

Downloading the library

Click here to download the latest version of the library ->

Download.gif

Installation

To use the library, add the Millennial Media library (jar file) to your project.

Using the Library

Permissions

Add the following permissions to AndroidManifest.xml:

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

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

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

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

The ACCESS_COARSE_LOCATION permission allows location information to be sent to Millennial Media, so that location targeted ads can be served to your app. If you do not wish to receive location targeted ads, this permission may be omitted.

Initialization

Using the XML file:

<com.jumptap.adtag.JtAdView
android:layout_width="fill_parent" android:layout_height="wrap_content"
	android:id="@+id/ad" jumptapLib:publisherId="add your publisher id"
	jumptapLib:siteId="add your site id" jumptapLib:spotId="add your spot id"
		/> 

Note: Make sure that you have the XML name space declaration for the Millennial Media Library in your 'LinearLayout' tag of your XML file. Name space declaration for the Millennial Media Library: xmlns:jumptapLib="http://www.jumptap.com/lib/android".


Using Java code:

JtAdWidgetSettings s = JtAdWidgetSettingsFactory.createWidgetSettings();
s.setPublisherId(your publisher id);
s.setSpotId(your ad spot id);
s.setSiteId(your site id);
JtAdView adView = new JtAdView(TestActivity.this, s);

Setting the Ad View Listener

To get notifications from the JtAdView widget implement the JtAdViewListener interface and set it using the JtAdView.setAdViewListener(listener) api.

JtAdView Methods

Optional methods of the JtAdView class

public void refreshAd() Refresh the ad now </pre>


Optional methods of the JtAdWidgetSettings class

public JtAdWidgetSettings copy()

Copy the instance of JtAdWidgetSettings to new instance that contains the same settings

Returns: New instance of JtAdWidgetSettings that contains the same setting

public java.lang.String getPublisherId()

Your "Publisher Id" as given to you by Millennial Media

Returns: String the publisher id

public void setPublisherId(java.lang.String publisherId)

set "Publisher Id" as given to you by Millennial Media

Parameters: publisherId - the new publisher id

public java.lang.String getSiteId()

"site" is optional and is used to specify additional applications (Millennial Media provided). "site" is used if you have multiple applications. Site is optional and is typically not provided if you only have one application. The site name is provided by Millennial Media

Returns: String site ID

public void setSiteId(java.lang.String siteId)

set "Site Id" as given to you by Millennial Media

Parameters: siteId - the new site id

public java.lang.String getSpotId()

"Ad Spot" is used to specify a specific page or section within the application (Millennial Media provided).

Returns: String spot id

public void setSpotId(java.lang.String spotId)

Set the ad spot ID as given to you by Millennial Media

Parameters: spotId - the new spot id

public java.lang.String getHostURL()

Http Host URL

Returns: String the Millennial Media server host url

public void setHostURL(java.lang.String host)

Set the host url for the Millennial Media server

Parameters: host - the new host url

public java.lang.String getUserAgent(WebView webView)

Return the WebView's user-agent string.

Parameters: webView - the webview that contains the user agent

Returns: String the WebView's user-agent string.

public java.lang.String getLanguage()

Provides user defined language id

Returns: String the defined language id

public void setLanguage(java.lang.String language)

Set new language id

Parameters: language - the new language

public java.lang.String getAdultContentType()

Which adult classification of ads can be returned

Returns: String user definde adult content

public void setAdultContentType(java.lang.String adultContent)

Set adult content. Use JtAdWidgetSettings.AdultContent class

Parameters: adultContent - set the allowed adult content tpye

public java.lang.String getPostalCode()

Provides user defined postal code

Returns: String the user definded postal code

public void setPostalCode(java.lang.String postalCode)

Set Postal code

Parameters: postalCode - the new postal code

public java.lang.String getCountry()

Provides user defined country

Returns: String user defined country

public void setCountry(java.lang.String country)

Set the country

Parameters: country - the new country

public java.lang.String getAge()

Provides user's age

Returns: String user's age

public void setAge(java.lang.String age)

Set the user's age

Parameters: age - the new age

public java.lang.String getGender() Provides user's gender

Returns: String user's gender

public void setGender(java.lang.String gender)

Set the user's gender

Parameters: gender - the user's gender

public java.lang.String getHHI()

Provides user's house hold income

Returns: String user defined house hold income

public void setHHI(java.lang.String hhi)

Set the house hold income

Parameters: hhi - the new house hold income

public int getRefreshPeriod()

Provides user defined refresh period 0 will indicate no refresh. refreshAd on the JtAdView needs to be used to retrieve ads if the refresh is set to 0.

Returns: String the user defined refresh period

public void setRefreshPeriod(int refreshPeriod)

Set the refresh period 0 will indicate no refresh

Parameters: refreshPeriod - the new refresh period

public java.lang.String getBundleVersion()

Get bundle version

Returns: bundle version

public void setAdFormat(java.lang.String adFormat)

Set the ad format

Parameters: adFormat - the new ad format

public java.lang.String getJtLibVer()

Get the Millennial Media Android SDK version

Returns: Millennial Media Android SDK version

public java.lang.String getVersion()

Get the version of the Millennial Media server API

Returns: Version of the Millennial Media server

public void setVersion(java.lang.String version)

Set the version of the Millennial Media server API

Parameters: version - the new version

public void setShouldSendLocation(boolean shouldSendLocation)

Boolean that controls whether location should be sent to Millennial Media servers. Default is true

Parameters: shouldSendLocation - if true location will be sent

public boolean isShouldSendLocation()

Returns whether the Millennial Media widget sends location to Millennial Media server

Returns: If true then location will be sent. If false location will not be sent

public Bitmap getAlternateImage()

Get the alternative image

Returns: alternative image

public void setAlternateImage(Bitmap alternateImage)

Set an alternate image that will be shown while the ad is retrieved. The alternative image has a higher priority than background color

Parameters: alternateImage - the alternative image

public int getBackgroundColor()

Get the background color that will be shown while the ad is retrieved

Returns: The background color

public void setBackgroundColor(int backgroundColor)

Set the background color that will be shown while ad getting processed Alternative image has higher priority to be shown then background color

Parameters: backgroundColor - the new background color

public void setDismissButtonLabel(java.lang.String dismissButtonLabel)

Set the label for the dismiss button label that will be shown when an interstitial is displayed

Parameters: dismissButtonLabel - the new dismiss button label

public java.lang.String getDismissButtonLabel()

Get the dismiss button label

Returns: dismiss button label

public void setInterstitialshowTime(int interstitialshowTime)

Set the interstitial display time is seconds. This parameter will determine how long the interstitial will be shown before automatically closing

Parameters: interstitialshowTime - the new interstitial show time in seconds

public int getInterstitialshowTime()

Get the user defined interstitial display time. The default is 60 seconds

Returns: the interstitial show time in seconds

public java.lang.String getOs()

Return the Android OS name

Returns: Android OS name

public void setApplicationId(java.lang.String appId)

Set the user's application ID ( e.g "com.test.foo")

Parameters: appId - user's application ID

public java.lang.String getApplicationId()

Return the application id. The default is empty string ("")

Returns: application id

public void setApplicationVersion(java.lang.String appVer)

Set your application version ( e.g "2.2.2")

Parameters: appVer - the application version of your app

public java.lang.String getApplicationVersion()

Return the application version. The default is empty string ("")

Returns: application version

Properties that can be set in XML

Property Notes Required
jumptapLib:publisherId Your "Publisher Id" as given to you by Millennial Media Y
jumptapLib:siteId Site is typically not provided if you only have one application. Site ID is provided by Millennial Media N
jumptapLib:spotId Used to specify a specific page or section within the application (Millennial Media provided). N
jumptapLib:language The user’s preferred language. Valid values are the ISO-639-1 2 letter language codes. http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes N
jumptapLib:category A category that best describes the page / site / application on which the ad is to be displayed.
  • The value of this parameter provides additional contextual targeting information to our ad server.
  • Please refer to Valid Categories for a list of valid category values.||N
jumptapLib:postalCode
  • If you are passing latitude/longitude, then the postalCode parameter should not be set.
  • The value of this parameter must be encoded.
  • If postal code is included in the request, the country parameter is required.
N
jumptapLib:country The two letter ISO country code of the originating user’s request. http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2.
  • Country should be passed only if the country of the user originating the ad request is definitively known; it should not be set for a static value for all of your requests.
  • If country is not included in the request, Millennial Media will automatically determine the country based on the user or gateway IP.
  • The country parameter is required if the postal code (pc) parameter is passed.
  • If you are passing latitude/longitude, then the country parameter should not be passed.
N
jumptapLib:age The user's age in years, if known. Valid values include any integer from 1-199. N
jumptapLib:gender The user's gender, if known. Valid values are 'm' or 'f' N
jumptapLib:hhi The user's household income in thousands, if known.
  • Valid values include
  • 000_015
    • Where household income is less than $15,000
  • 015_020
    • Where household income is $15,000-$19,999
  • 020_030
    • Where household income is $20,000-$29,999
  • 030_040
    • Where household income is $30,000-$39,999
  • 040-050
    • Where household income is $40,000-$49,999
  • 050-075
    • Where household income is $50,000-$74,999
  • 075-100
    • Where household income is $75,000-$99,999
  • 100_125
    • Where household income is $100,000-$124,999
  • 125_150
    • Where household income is $125,000-$149,999
  • 150_OVER
    • Where household income is $150,000 or higher
N
jumptapLib:alternateImage The image that will be shown while the ad is retrieved. The alternative image has higher priority to be shown than background color. N
jumptapLib:jumptapLib:alternateColor Set the background color that will be shown while the ad is retrieved. The Alternate image has higher priority for display than background color N
jumptapLib:refreshPeriodInSec Ad refresh time in seconds. 0 will indicate no refresh (That is, refreshAd will need to be called to retrieve an ad). Default is 60 seconds. N
jumptapLib:dismissLabel Button label for dismissing an interstitial ad. N
jumptapLib:interstitialTime This parameter sets the time an interstitial will be shown before automatically closing. N
jumptapLib:applicationId application Id ( e.g "com.test.foo").Used for event tracking. N
jumptapLib:applicationVersion This is your current application version ( e.g "2.2.2"). Used for event tracking N

Frequently Asked Questions

  1. How do I know if no ad is returned?
  2. If a new ad is retrieved JtAdViewListener. onNewAd,(JtAdView widget, int widgetId,String responseContent) is called.
    If no ad is returned JtAdViewListener.onNoAdFound(JtAdView widget, int widgetId) is called.
    If an error occurs (network error, etc.), JtAdViewListener. onAdError ,(JtAdView widget, int widgetId, int errorCode) is called.
    You can implement JtAdViewListener interface and override those methods (to show a house ad, call another ad provider, or hide the ad widget)
  3. How do I implement an interstitial with the Millennial Media Android SDK?
  4. <com.jumptap.adtag.JtAdInterstitial
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:id="@+id/inter" jumptapLib:publisherId="add your publisher id"
    jumptapLib:siteId="add your site id" jumptapLib:spotId="add your spot id" />
    
    //create JtAdWidgetSettings instance
    JtAdWidgetSettings s = JtAdWidgetSettingsFactory.createWidgetSettings();
    		
    //set publisher Id - your publisher Id
    s.setPublisherId(set publisher Id);
    //set spot Id - your spot Id
    s.setSpotId(set spot Id);
    /* add other settings here*/
    
    JtAdInterstitial inter = null;	
    try {
    	inter = new JtAdInterstitial(this, s);
    } catch (JtException e) {
    	e.printStackTrace();
    	finish();
    	return;
    }
    inter.setAdViewListener(this);
    setContentView(inter);
    
    To dismiss the interstitial before timeout and before user dismissal:
    inter.dismmiss();
    
    To show the interstitial in popup:
    inter.showAsPopup();
    
  5. Interstitial close button is not working
A. Implement onInterstitialDismissed method to close the interstitial.
B. Using setAdViewListener method set the interstitial listener.

For example:

inter.setAdViewListener(new JtAdViewListener() {
                  
      @Override
      public void onNoAdFound(JtAdView arg0, int arg1) {
      // TODO Auto-generated method stub
                        
      }
                  
      @Override
      public void onNewAd(JtAdView arg0, int arg1, String arg2) {
      // TODO Auto-generated method stub
                        
      }
                  
      @Override
      public void onInterstitialDismissed(JtAdView arg0, int arg1) {
      inter.setVisibility(View.GONE); //just a suggestion
                        
      }
                  
      @Override
      public void onFocusChange(JtAdView arg0, int arg1, boolean arg2) {
      // TODO Auto-generated method stub
                        
      }
                  
      @Override
      public void onAdError(JtAdView arg0, int arg1, int arg2) {
      // TODO Auto-generated method stub
                        
      }
});
Personal tools