请仔细看一下密码。用于AdWhirl与Android平台中的AdMob集成。
在AndroidManifest.xml中
<activity android:name="com.google.ads.AdActivity"
android:configChanges="orientation|keyboard|keyboardHidden" />
<meta-data android:value="719308a6f08e4d68bf3158161fb45f99"
android:name="ADWHIRL_KEY" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
在布局中,在你想显示广告的地方放置一个线性布局。
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/AdLayout">
</LinearLayout>
现在在Java文件中:
private LineaLayout mAdLayout;
@Override
public void onCreate(Bundle savedInstanceState)
{
mAdLayout = (LinearLayout) findViewById(R.id.AdLayout);
AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);
RelativeLayout.LayoutParams adWhirlLayoutParams =
new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
int mAdWidth = 320;
int mAdHeight = 75;
AdWhirlTargeting.setAge(23);
AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);
AdWhirlTargeting.setKeywords("ketan patel android");
AdWhirlTargeting.setPostalCode("94123");
AdWhirlTargeting.setTestMode(false);
DisplayMetrics mDisplayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics);
mAdHeight = mDisplayMetrics.heightPixels;
float mDensity = mDisplayMetrics.density;
mAdWidth = mDisplayMetrics.widthPixels;
mAdHeight = (int) (mAdHeight * mDensity);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(Usage.this,
"719308a6f08e4d68bf3158161fb45f99");
adWhirlLayout.setAdWhirlInterface(Usage.this);
adWhirlLayout.setMaxWidth(mAdWidth);
adWhirlLayout.setMaxHeight(mAdHeight);
adWhirlLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
mAdLayout.setGravity(Gravity.CENTER_HORIZONTAL);
mAdLayout.addView(adWhirlLayout, adWhirlLayoutParams);
mAdLayout.invalidate();
}
**Here 719308a6f08e4d68bf3158161fb45f99 is the SDK Key from AdWhirl Account.
**Put AdWhirlSDK_Android_3.0.0.jar and GoogleAdMobAdsSdk-4.1.0.jar
files into libs folder and reference those using
Java BuildPath from the properties.
谢谢。
我希望这能帮助你。