AdWhirl 集成说明

 

Android SDK Setup

 

The AdWhirl for Android SDK maximizes your app’s advertising revenue via trivial integration of up to four mobile ad networks:

  1. AdMob
  2. Google AdSense for Mobile Applications
  3. Millennial Media
  4. ZestADZ

 

These instructions assume familiarity with basic Android development, Eclipse configuration and the AdWhirl mediation service.

Display of AdWhirl-mediated ads requires four simple additions to your app.

1. AdWhirl

To leverage AdWhirl your app must invoke the ad network abstractions in the AdWhirl SDK JAR. Add the JAR to your project’s Java Build Path:

2. Ad Networks

Once you’ve registered with a specific mobile ad network as a publisher and downloaded its SDK, incorporating it into your app involves:

  1. Adding the network SDK JAR to your project’s Java Build Path – just like AdWhirl’s above
  2. Allocating traffic to the network via the AdWhirl service’s Ad Network Settings page

It’s that easy.

Please see Google AdSense for Mobile Applications Configuration below for a few additional AdSense-specific configuration notes.

3. Permissions

In order for your app to access the AdWhirl service and ad networks it must obviously have android.permission.INTERNET. Some network SDKs may also utilizeandroid.permission.ACCESS_COARSE/FINE_LOCATION for location-based advertising and android.permission.READ_PHONE_STATE.

4. AdWhirlLayout

Finally, to display the mediated ads simply configure AdWhirlTargeting as appropriate and add an AdWhirlLayout to your Activity view hierarchy.

4.1 Java

public class HelloAdWhirl extends Activity implements AdWhirlInterface {

 public void onCreate(Bundle savedInstanceState) {

   super.onCreate(savedInstanceState);

   setContentView(R.layout.main);

 

   AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);

 

   AdWhirlTargeting.setAge(23);

   AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);

   AdWhirlTargeting.setKeywords("online games gaming");

   AdWhirlTargeting.setPostalCode("94123");

   AdWhirlTargeting.setTestMode(false);

 

   AdWhirlLayout adWhirlLayout = (AdWhirlLayout)findViewById(R.id.adwhirl_layout);

   

   TextView textView = new TextView(this);

   RelativeLayout.LayoutParams layoutParams = new

     RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,

                                 LayoutParams.WRAP_CONTENT);

   int diWidth = 320;

   int diHeight = 52;

   int density = getResources().getDisplayMetrics().density;

 

   adWhirlLayout.setAdWhirlInterface(this);

   adWhirlLayout.setMaxWidth((int)(diWidth * density));

   adWhirlLayout.setMaxHeight((int)(diHeight * density));

 

   layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);

   textView.setText("Below AdWhirlLayout");

 

   LinearLayout layout = (LinearLayout)findViewById(R.id.layout_main);

   

   layout.setGravity(Gravity.CENTER_HORIZONTAL);

   layout.addView(adWhirlLayout, layoutParams);

   layout.addView(textView, layoutParams);

   layout.invalidate();

 }

}

4.1 XML

While previous releases required direct AdWhirlLayout instantiation in order to provide an SDK key...

AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this,

                                               "643eb700781e4f47b017ea27d1aba3be");

...this value may now be specified at either the application or activity level via the XML attribute ADWHIRL_KEY.

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

 package="com.adwhirl" android:versionCode="1" android:versionName="1.0">

 <application android:icon="@drawable/icon" android:label="@string/app_name"
    android:debuggable="true">

    <activity android:name=".Invoker" android:label="@string/app_name">

      <intent-filter>

        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />

      </intent-filter>

      <meta-data android:value="643eb700781e4f47b017ea27d1aba3be"

        android:name="ADWHIRL_KEY"/>

    </activity>

 

Keys for specific layouts trump any application-level value.

 

5 Google AdSense for Mobile Applications Configuration

Google AdSense for Mobile Applications features one requirement and two options not currently supported by AdWhirl’s adapter abstraction.

5.1 Company and App Names

Google AdSense for Mobile Applications requires company and app names uniquely identifying your app. Failure to provide these values via the AdWhirlAdapter staticssetGoogleAdSenseCompanyName and setGoogleAdSenseAppName will disable AdSense ads.

5.2 AdSense Channel ID

You may optionally also specify an AdSense channel ID via AdWhirlAdapter.setGoogleAdSenseChannel to better track your app’s performance.

5.3 Expandable Ads

Specifying an expand direction of either “BOTTOM” or “TOP” via AdWhirlAdapter.setGoogleAdSenseExpandDirection will enable AdSense’s expandable ads.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值