wp7 中使用微软AD

在XNA中使用


1. 程序ID和广告布局

private static readonly string ApplicationId = "test_client";
private static readonly string AdUnitId = "Image480_80"; //other test values: Image480_80, Image300_50, TextAd


2. Initialize中
{
    AdGameComponent.Initialize(this, ApplicationId);
    Components.Add(AdGameComponent.Current);

    DrawableAd bannerAd = AdGameComponent.Current.CreateAd(AdUnitId, new Rectangle(x, y, 480, 80), true);
    bannerAd.ErrorOccurred += new EventHandler<Microsoft.Advertising.AdErrorEventArgs>(bannerAd_ErrorOccurred);
    bannerAd.AdRefreshed += new EventHandler(bannerAd_AdRefreshed);

    AdGameComponent.Current.Enabled = false;
    //在取到地理位置信息后将地理位置设置给AD,然后AdGameComponent.Current.Enabled 置为true。 
    //如果gps状态为GeoPositionStatus.Disabled或GeoPositionStatus.NoData, 也置为true
}


在SilverLight中使用


下面是写在cs中间中的方式。写在xaml中类似

            AdControl adControl = new AdControl("test_client",   // ApplicationID
                                                "Image480_80",   // AdUnitID
                                                true);           // isAutoRefreshEnabled
            // Make the AdControl size large enough that it can contain the image
            adControl.Width = 480;
            adControl.Height = 80;
            adControl.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            ContentPanel.Children.Add(adControl);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值